LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Need help with WWW redirection in apache (https://www.linuxquestions.org/questions/linux-networking-3/need-help-with-www-redirection-in-apache-466230/)

ice99 07-21-2006 08:36 AM

Need help with WWW redirection in apache
 
How can I redirect my domain to show 'www' in front of it. For example when someone type my domain name into a browser without the www, I want the domain to automatically default to the www, when it comes up ex. So when user enter mydomain.com I want him to be redirected directly to www.mydomain.com and automaticly to see www.mydomain.com n the addressbar insted od mydomain.com. I need this to be setup in a virtual host directive in my httpd.conf file

Thanks in advance

DrAxeman 08-02-2006 12:15 AM

You wouldn't do it entirely in apache.

Step 1. Create seperate virtual host entries for both www.website.com and website.com Have website.com use a different directory.

Step 2. Create an index.html page the does auto redirection. To do this put the following in the <HEAD> section.

<META HTTP-EQUIV="Refresh"
CONTENT="1; URL=html-redirect.html">

That should do it.

benjithegreat98 08-02-2006 11:02 AM

Here are 2 site from a quick google search that explain the redirect directive in virtualhosts:

http://yost.com/computers/apache-redirect/
http://www.cgi-interactive-uk.com/ap...directive.html

DrAxeman 08-06-2006 12:02 AM

That's useful info.


All times are GMT -5. The time now is 02:08 PM.