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 want to test for test.com and serve a particular file if I find it anywhere in the request, and if I don't find it move on to the rest of the rules. I can't get it to consistently do this.

RewriteRule ^/test.com /var/www/html/index.html [NC,L]

share|improve this question
    
Can you clarify what you mean? Are you looking to act on requests sent to test.com, or ones with test.com as part of the file or directory structure in the request? –  Shane Madden Sep 14 '11 at 22:09

1 Answer 1

The ^ means start of line/string, so requests to http://example.com/test.com and https://www.example.com/test.com_with_more should match, but http://example.com/in_front_test.com would not match. Try removing the ^ and prefix the . with a \ so that it matches a . and not any char use

RewriteRule test\.com /var/www/html/index.html [NC,L]

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule was used as a reference.

share|improve this answer
    
Thanks for your response, it's very helpful. I'm still having an issue with www.test.com vs test.com. I would think the folliowing would match either, but it doesn't seem to be the case: RewriteRule test\.com /var/www/html/index.html [NC,L] –  d_b_g Sep 15 '11 at 14:12
    
I would think it would work too. Does example.com/in_front_test.com work, but not example.com/www.test.com? –  becomingwisest Sep 15 '11 at 18:06

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.