Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 am not able to get through with this code...I need to capture the request but with this code I am able to redirect but it cannot find the particular search page.

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

can any one tell me what is I am missing??

share|improve this question
in your regex you have [A-Z]+... are sure you always have all caps for you directories? Please give an example of what it should be finding. – DBruns May 19 '10 at 13:25
@DBruns, since the condition is using %{THE_REQUEST}, the [A-Z]+ actually matches "GET" (or "POST", or whatever the request method was) – Brian May 20 '10 at 21:09

In your RewriteRule, you don't capture anything, but then you reference %2...? RewriteRule won't operate on the captured data from the regex in RewriteCond.

Update: Actually, now that I'm reading your code more closely, it looks like you don't need the RewriteCond. If you're just trying to rewrite one URL as another, you can do something like this:

RewriteRule ^searcha\.php\?name=(www\.)?([^/\ ]+)[^\ ]* [R=301,L]

(You might have to tweak that regex some more since I'm not sure what you're trying to match)

share|improve this answer
could you give some example?? – mathew May 19 '10 at 15:09
ok I will explain I am going to launch an SEO site wich gives you lots of information on SEO by searching any URLS so when on my search page when some one enter say then it should catch that URL to searcha.php where processing will happen and address line should rewrite to this is what I am looking into – mathew May 19 '10 at 16:03
Do you intend searcha.php to do anything? Because if you rewrite the URL, it will never actually get hit. You might be better off redirecting in PHP by sending a "Location" header (see – Brian May 19 '10 at 17:15

Your Answer


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