wiggst3r Posted April 22, 2009 Share Posted April 22, 2009 Hi I'm trying to setup a redirect so when users go to my site by typing in either www.example.com or simply example.com they are always redirected to www.example.com My current virtual host is: <VirtualHost xx.xx.xx.xx:80> ServerAdmin [email protected] ServerName www.exmple.com ServerAlias exmple.com DocumentRoot /var/www/example/current/ ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On </VirtualHost> What do I need to cgane to achieve this? Thanks Link to comment https://forums.phpfreaks.com/topic/155156-virtualhost-redirect/ Share on other sites More sharing options...
trq Posted April 22, 2009 Share Posted April 22, 2009 RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule ^/(.*)$ http://www.example.com/$1 [R=301,L] Link to comment https://forums.phpfreaks.com/topic/155156-virtualhost-redirect/#findComment-816335 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.