LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Redirecting domain.com to www.domain.com (https://www.linuxquestions.org/questions/linux-general-1/redirecting-domain-com-to-www-domain-com-445941/)

rustyz82 05-18-2006 12:29 AM

Redirecting domain.com to www.domain.com
 
Ok the subject says it well enough. I have domain.com and want it so anytime that someone types domain.com it automagically redirects to www.domain.com, same for pages, such as domain.com/content.php should redirect to www.domain.com/content.php. I have read a few posts on 301 redirects but can't seem to get it to work. I can do this on the httpd.conf level or in the .htaccess file for the domain, either works. Here is my current Virtual host enty for this domain:

Code:

<VirtualHost xx.xx.xx.xx>
ServerAlias domain.com
ServerAdmin admin@domain.com
DocumentRoot /home/domain/public_html
BytesLog domlogs/domain.con-bytes_log
ServerName www.domain.com
ScriptAlias /cgi-bin/ /home/domain/public_html/cgi-bin/
DirectoryIndex index.php index.htm index.html index.cgi
User domain
Group domain
CustomLog /usr/local/apache/domlogs/domain.com combined
</VirtualHost>

My current .htaccess file is blank. Any help is appriciated.

vikasumit 05-18-2006 03:16 AM

Hi,

Just a quick note, you can use
"redirect" directive, I am not sure if it handle Regular expression.

you can also do this programmatically from within your Scripts.

rustyz82 05-18-2006 03:28 AM

I had tried a redirect but I wasn't working. I assume somehting was wrong with my code. My provider got it working and i'm waiting for the code he used so I can figure out what I did wrong. I'll post it here once I have it, so others can see for future ref.

bathory 05-18-2006 03:41 AM

It should be something like:
Code:

ServerName www.domain.com
ServerAlias domain.com *.domain.com



All times are GMT -5. The time now is 03:57 PM.