Apache rewrite question
I would like to redirect any url which doesn't have www.domain.org to www.domain.org.
For example: http://google.com --> http://www.google.com but, http://test.google.com --> http://test.google.com I hope that make sense, and i hope there are apache guru's out there who can help me. I need this solution for multiple domains so not google.com specific solution. Thanks in advance. |
Are you trying to host several different sites on the same sever without multiple I.Ps? Is so you must create virtual hosts for each site and then add the I.P address and host name to your etc/hosts file. A virtual host looks like this (add these to your httpd.conf file, change the domain names to your sites names, change the document root to the directories you wish:
<VirtualHost *> ServerName www.domain.com DocumentRoot /www/domain </VirtualHost> <VirtualHost *> ServerName www.otherdomain.com DocumentRoot /www/otherdomain </VirtualHost> After you have done that, add these names to your hosts file, and give them the same I.P. adress. For instance if the name is www.domain.com and the i.p adress is 192.168.1.1, your hosts file would look like this 192.168.1.1 www.domain.com 192.168.1.1 www.theotherdomain.com Apache will route to the proper site depending on the URL, you can host several different sites on the same box with the same I.P address. kind of like Host Headers in IIS. |
Check out the URL Rewriting Guide on the Apache website. It's in the docs section for the 1.X branch.
|
Thanks for responses.
I am using mass virtual hosting format. and i tried reading the url rewriting guide but its beyond my skillset :( unfortunately. |
All times are GMT -5. The time now is 08:31 AM. |