Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I searching for a redirection code for my url:

what I want is when some one search in my site it should redirect

example: if some one search on mysite

then in address line it should look like

can be in $_POST method or $_GET

how do I do that??

share|improve this question
RewriteEngine On
RewriteCond %{HTTP_REFERER} google\.com
RewriteRule ^.*$ [R,L]

in an .htaccess file might work, i have not tested it.

you could try:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(.*)\/search\.php\?q=(www\.)?([^/\ ]+)[^\ ]*\ HTTP/
RewriteRule ^.*$ [R,L]

this link also has some other example 'smart' .htaccess rules:

share|improve this answer
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /search\.php\?q=(www\.)?([^/\ ]+)[^\ ]*\ HTTP/ this is for request of any kind of search domains..but what I dont know is how do I convert to – mathew May 19 '10 at 8:47
added another potential answer – cpbills May 19 '10 at 8:57
nop it doesnt work – mathew May 19 '10 at 9:39
does it do /anything/ can you provide more information as to how it doesn't help? maybe enable logging for RewriteRules RewriteLog file-path and RewriteLogLevel 9 you also have to be willing to play with the regular expression in the RewriteCond to see if you can at least get it to trigger. i don't know where you got that pattern, so i have no idea if it should work or not, you provided it. – cpbills May 19 '10 at 16:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.