I’m trying to remove a PHP Get query from my domain. For example, instead of showing example.com/?url=1234, I’d like it to rewrite to example.com/1234, hiding the query but not removing it. I know this is possible and have read many tutorials on how to do this, but my code just isn’t working. Here’s what I’m currently trying:
RewriteEngine On
RewriteCond %{QUERY_STRING} url=
RewriteRule (.*) http://example.com/$1? [R=301]
What this is doing is stripping the query entirely, instead of just removing the ?url= segment.
You are thinking about it the wrong way round. Rewriting is not something that the client sees, but something that are exclusive to the server.
This means that you can make example.com/1234 work as though the client had used example.com?url=1234.
To achieve this you would use the following lines: