Would someone please help me with a rewrite rule to go from http://domain.com/search.php?q=search+terms to http://domain.com/cgi-bin/search.cgi?query=search+terms Thanks in advance for any help. *Edit: I'd like it to produce a 301 response too
Here you go : RewriteRule ^search\.php\?q=([^/\.]+)$ /cgi-bin/search.cgi?query=$1 [R=301,L] Code (markup): It produces a 301 Permanently Moved response too.
Thankyou, but it doesn't seem to be working for me. Here is what I have in there; Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L] RewriteRule ^search\.php\?q=([^/\.]+)$ /cgi-bin/search.cgi?query=$1 [R=301,L] Code (markup):
Oh, I forgot that RewriteRule doesn't look at the query string. Here you go : RewriteCond %{QUERY_STRING} ^q=([^/\.]+)$ RewriteRule ^search\.php /cgi-bin/search.cgi?query=%1 [R=301,L] Code (markup):
Thanks for trying again, but I managed to get it sorted out using another method. I found out that rewrite rules don't work with cgi-bin URLs on most hosts... as the cgi-bin isn't below the htdocs folder. I ended up creating a file search.php and just put this in it; header("Location: http://domain.com/cgi-bin/search.cgi?query=$q",TRUE,301);
The above mod_rewrite solution should've worked too.(I'd encourage you to try it). But I'm glad you've been able to solve it by yourself.