Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ^.*$ http://www.mydomain.com/%2? [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

1 Answer 1

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\.)?([^/\ ]+)[^\ ]* http://www.mydomain.com/%2 [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 www.google.com then it should catch that URL to searcha.php where processing will happen and address line should rewrite to www.mydomain.com/www.google.com 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 php.net/header). –  Brian May 19 '10 at 17:15

Your Answer

 
discard

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