Rewrite a URL variable into an HTML file
-
06-05-2021 - |
Question
I've seen many cases of these rewrite questions but I don't get all the regular experessions and browser errors and such so I was hoping that someone could help me.
Ok, so I have a file with a url variable 'pages.php?p=foo' and I would like to rewrite it so that it appears as 'foo.html' in the same directory.
I was thinking along the lines of:
RewriteRule (.+).html pages.php?p=$1
The trouble is, the browser displays 400 Bad Request errors.
I'm hoping there's a fix for this but I can't get my head around it.
Any help is much appreciated :)
No correct solution
OTHER TIPS
Try this:
RewriteRule (.*)\.html pages.php?p=$1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow