I’m using this:
RewriteRule ^(.+)/?$ index.php?slug=$1 [L]
to change what the user sees as:
example.com/hello/world
to what the server sees as:
example.com/index.php?slug=hello/world
But it doesn’t work. I know the .htaccess itself is working because I have tried other, simpler rules that I’ve used elsewhere ans they work fine. Is there something wrong with this one?
Thank you!
Don’t process the rule if the file or directory actually exists. This will prevent the rule from acting on
index.phpand causing a rewrite loop. It will also prevent it from affecting your static content (css, js, images).Note, per comments,
[QSA]is added to ensure that the existing query string parameters are preserved across the rewrite.