My URLs look like http://example.com/?n=x
. I want the URL to show as http://example.com/
. I have used to approaches so far and none of them works.
First one is based on this question:
RewriteEngine On RewriteCond %{QUERY_STRING} ^n=1$ RewriteRule (.*) $1? [R=permanent]
After the answer below I modified the .htaccess file:
```RewriteEngine On
RewriteCond %{QUERY_STRING} ^n=(.*)$
RewriteRule (.*) $1? [R=permanent]```
but it still did not work. Here is the debugging info:
RewriteCond %{QUERY_STRING} ^n=(.*)$
This condition was met.
RewriteRule (.*) $1? [R=permanent]
The new url is http://example.com/blog/cat/??
Test are stopped, a redirect will be made with status code permanent
Second approach is:
RewriteEngine On RewriteCond %{QUERY_STRING} !^$ RewriteRule ^(.*)$ $1 [QSD]
None of them seem to work.
I have a few more questions:
- Does rewriting only work if the URL is not typed manually?
- Can I still access the values of query strings in PHP?
- What happens when a user copies the rewritten URL?