I attempt to re-write a URL which have this type:


for this form:


I am unable to find.

I attempted this type for instance: RewriteRule ^?q=home$ /home [R=301,L]

Appears like the "?" or even the "=" are appearing problem? Are you able to assist me to?


Everything following the ? is incorporated in the variable %{QUERY_STRING}.

To rewrite only the value home use:

RewriteCond %{QUERY_STRING} ^q=home$
RewriteRule ^ /home? [L,R=301]

To rewrite all q values to static URIs use:

RewriteCond %{QUERY_STRING} ^q=(.*)$
RewriteRule ^ /%1? [L,R=301]

The final ? within the RewriteRule removes the query string in the target URI.

Reference: Apache mod_rewrite