BigWater BigWater - 4 months ago 26
Apache Configuration Question

htaccess search query

In the .htaccess file (apache) how would I change a rewrite search query:

test.com/search?q=cats


to

test.com/Search?q=cats


Capitalize the 'S' in search.

Thanks!

Answer

If you are already using mod_rewrite or want to use it:

RewriteEngine on
RewriteBase "/"
RewriteRule ^search Search

To make it externally visible it needs to be an external redirect:

RewriteEngine on
RewriteBase "/"
RewriteRule ^search Search [R,L]

Alternatively you can redirect with a simpler directive:

Redirect 301 /search /Search