Forum Moderators: phranque
I have succesfully used the following rewrite rule:
RewriteRule (.+).html /index.php?path=/$1.html [nc]
I also had to put in various rules to ignore certain directories:
RewriteCond %{SCRIPT_FILENAME}!.*stats.*
RewriteCond %{SCRIPT_FILENAME}!.*phpMyAdmin.*
This worked quite succesfully however with the rewrite rule I can only process pages with the path as indexed in their database entry, I can not parse any get variables via the url string as anything after .html is ignored.
So I thought that:
RewriteRule ^(.*) index.php?path=$1 [NC]
However I have a little problem. Any URL that I enter returns index.php?path=index.php for instance /test/index.html should return index.php?path=/test/index.html however it doesnt.
Please help
RewriteRule (.+).html /index.php?path=/$1.html [nc]IE if the path ends with .html then send it to the script.
Actually, the way that really works is: "if the path ends with <any character>html, then send it to the script."
You'll need to escape the period if you want it interpreted literally, since "." is a regular-expressions token meaning, "match any single character." Also, do not feel free to vary the case of directives or flags. Try:
RewriteRule (.+)\.html$ /index.php?path=/$1.html [NC,L]
I also had to put in various rules to ignore certain directories:RewriteCond %{SCRIPT_FILENAME} !.*stats.*
RewriteCond %{SCRIPT_FILENAME} !.*phpMyAdmin.*
These can be shortened to
RewriteCond %{SCRIPT_FILENAME} !stats
RewriteCond %{SCRIPT_FILENAME} !phpMyAdmin
So I thought that:RewriteRule ^(.*) index.php?path=$1 [NC]
would do the trick...
To fix that problem explicitly, as well as another literal-period problem, use:
RewriteCond $1 !index\.php$
RewriteRule (.*) index\.php?path=$1 [NC,L]
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim