Will this redirect work [a-z]* to example.com

ie., I want to redirect anything to example.com

Thanks Jean

link|improve this question

25% accept rate
feedback

2 Answers

Putting RedirectPermanent / http://example.com/ in your Apache httpd configuration should do the trick.

link|improve this answer
feedback

If you want to redirect anything to example.com, what you probably want is something like this:

RewriteRule ^[a-z]*$ http://www.example.com [R,L]

This will redirect ANY request made to the any part of your URL to http://www.example.com. I.e.,

http://mysite.com => http://www.example.com
http://mysite.com/asdasd => http://www.example.com
http://mysite.com/another/test => (not forwarded)
link|improve this answer
and if I want to redirect example.net to example.com, do I write something like this---------------------------><VirtualHost *:80> ServerName y.com ServerAlias *.y.com Redirect permanent / x.com </VirtualHost> – Jean Nov 1 '10 at 7:23
I may have misunderstood your question. I thought you were only trying to forward requests that matched a pattern. If you just want to have the entire domain forwarded, joschi's answer is the better one. – Andrew M. Nov 1 '10 at 7:26
my question stands as it is. But I got confused with the adding of virtual host in the httpd.conf and the rewriterule. I want to add it to the httpd.conf than to the www directory – Jean Nov 1 '10 at 7:37
In the case of RewriteRule, you can add it inside or outside a VirtualHost directive. Adding it to the VirtualHost will only rewrite for requests matching that host. – Andrew M. Nov 1 '10 at 7:46
feedback

Your Answer

 
or
required, but never shown

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