Rewrite rule for webtemplate system

October 3, 2014 1.3k views


Now I'm developing web template system so I want to develop at one folder to ease for maintaining.

I want user visit

if user go deeper like

and deeper

I try many rewrite rules but does work, this one should work but failed again

RewriteEngine On
RewriteRule ^/~([^/]+)(.*) /template$2?param=$1 [PT,QSA]

please advice

1 Answer

This rewrite rule should do what you are looking for:

RewriteEngine On
RewriteBase  /template
RewriteRule ^\~(.*?)\/(.*) /$2?param=$1 [PT,QSA]

There is an online htaccess tester tool that is extremely useful for debugging and testing rewrite rules. It's a great resource for working on something like this.

Have another answer? Share your knowledge.