Reputation: 121
I had this rewrite rule in my httpd conf file:
RewriteRule (.*?)\.html $1.php?%{QUERY_STRING} [NC]
It worked fine. But when I place it into my .htaccess for that same virtual host, it's now returning the entire document path for $1 instead of the http host. All it needs to do is replace "html" with "php".
I obviously I don't understand how .htaccess works with rewrite rules.
Upvotes: 1
Views: 72
Reputation: 1308
My eyes nearly bleed looking at that ugly thing...
RewriteRule ^(.*).html?(.*)$ $1\.php?$2 [NC]
Upvotes: 0
Reputation: 143916
You need to add a leading slash in your rule's target:
RewriteRule (.*?)\.html /$1.php?%{QUERY_STRING} [NC]
Also, you can get rid of the ?%{QUERY_STRING}
bit in the target as well. Query strings are automatically appended if there isn't a ?.
Upvotes: 1