LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-15-2007, 03:09 PM   #1
mcupples
Member
 
Registered: Jun 2006
Location: Orlando
Distribution: FC3, FC5, CentOS4, Ubuntu 6.06
Posts: 57

Rep: Reputation: 15
HTTPD Redirect Issue


Hey Guys,

I want to redirect all incoming traffic to example.com to go to www.example.com. How would I go about doing this? Here's what I have and it's not working. I resorted to javascript to fix the issue for now, but I'd prefer to have apache do the work.

Code:
<VirtualHost 12.34.56.78>
DocumentRoot /home/example/public_html
ServerName www.example.com
ServerAlias example.com
ScriptAlias /cgi-sys/ /var/www/cgi-sys/
ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/
<Directory "/home/example/public_html/cgi-bin">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>
CustomLog logs/example.com-access_log combined
ErrorLog logs/example.com-error_log
</VirtualHost>

 <VirtualHost example.com>
  DocumentRoot /home/example/public_html
  ServerName www.example.org
  #ServerAlias example.org
  Redirect permanent / http://www.example.com
 </VirtualHost>
Another question, which would be the fastest alternative? Having php header you over, javascript check the

Code:
window.location.href.indexOf('www.example.com') != -1
or having apache do it?
 
Old 05-15-2007, 03:28 PM   #2
roreilly
Member
 
Registered: Aug 2006
Location: Canada
Distribution: Debian, Slackware
Posts: 106

Rep: Reputation: 28
Here's one of my redirects. Hostnames changed for protection purposes.

<VirtualHost mail.mydomain.com:80>
ServerName mail.mydomain.com
DocumentRoot /var/www/htdocs/webmail
Redirect / https://mail.mydomain.com/
</VirtualHost>
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scripting telnet sessions, redirect issue farkus888 Solaris / OpenSolaris 4 03-03-2007 02:18 PM
Apache URL issue - will redirect help... rlprofessional Linux - Newbie 9 06-16-2006 11:43 AM
httpd issue LinuxLala Linux - Networking 8 01-02-2004 02:59 AM
Virtual Host Redirect Issue DigiDave Linux - Software 1 10-23-2003 01:40 PM
ip redirect issue loser122 Linux - Networking 1 09-30-2003 01:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:46 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration