CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 6 - General Support
  Web Redirect Help

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread
  •  robin339
      robin339
Web Redirect Help
#1
Peeking in the Member Window
Joined: 2011/11/11
From
Posts: 18
Hi Guys,
I have a few vhosts pointing to my www.mainsite.com

My httpd.conf:
<VirtualHost 1.2.3.4:80>
RewriteEngine On
Redirect 301 / http://www.mainsite.com/
DocumentRoot "/var/www/html"
ServerName site1.com
ServerAlias www.site1.com
<Directory "/var/www/html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost 1.2.3.4:80>
RewriteEngine On
Redirect 301 / http://www.mainsite.com/
DocumentRoot "/var/www/html"
ServerName site2.net
ServerAlias www.site2.net
<Directory "/var/www/html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^/(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


The problem I am running into is, its only forwarding http://site1.com NOT http://www.site1.com

I want to be able to forward both www and non-www to my main site using httpd.conf.

Thanks in advance.
Robin
Posted on: 2012/1/20 20:48
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com