301 redirect from ?search= to ?s=

Using mod_rewrite to handle various content issues

301 redirect from ?search= to ?s=

Postby omBRE » Fri Aug 15, 2008 12:58 pm

I want to create unique search for complete website.
I have lot of categories, and every category has its own search.
for example:
Code: Select all
category1.html?search=...
category2.html?search=...
category3.html?search=...


i have changed that and right now it is:
Code: Select all
category1.html?s=...
category2.html?s=...
category3.html?s=...


I tried this:
Code: Select all
Redirect 301 categoryX.html?search=(.*)$ http://www.mysite.com/categoryX.html?s=$1

and it's not working...

Ideally I would need something like this:
[code]
Redirect 301 (.*).html?search=(.*)$ $1.html?s=$2
[code]

How can I make such redirection?


P.S.
My real category names are not really category1, category2, they have real names... so category([0-9]) wont work for me...
omBRE
 
Posts: 4
Joined: Fri Aug 15, 2008 12:49 pm

Postby richardk » Sat Aug 16, 2008 3:09 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?search(=[^&]+(&.*)?)$ [NC]
RewriteRule ^([^/]+\.html)$ /$1?%1s%2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Content

Who is online

Users browsing this forum: No registered users and 13 guests

cron