LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-18-2006, 12:29 AM   #1
rustyz82
Member
 
Registered: May 2004
Posts: 49

Rep: Reputation: 15
Post 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.
 
Old 05-18-2006, 03:16 AM   #2
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Rep: Reputation: 15
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.
 
Old 05-18-2006, 03:28 AM   #3
rustyz82
Member
 
Registered: May 2004
Posts: 49

Original Poster
Rep: Reputation: 15
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.
 
Old 05-18-2006, 03:41 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,924

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
It should be something like:
Code:
ServerName www.domain.com
ServerAlias domain.com *.domain.com
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual host www.domain.com work, domain.com don't work stormrider_may Linux - Networking 4 05-03-2006 09:52 PM
Cant get entry in bind to work with domain.com instead of www.domain.com pxes351 Linux - Networking 12 05-09-2005 06:20 AM
Domain resolves with no www... ServerStorm Linux - Software 20 11-15-2004 10:12 AM
www.domain.com instead of domain.com pyrombca Linux - Software 1 11-04-2004 02:36 PM
The WWW part in my domain msditech Linux - Newbie 0 12-09-2001 09:36 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration