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 test@exmple.com 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 Quote 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] Quote Link to comment https://forums.phpfreaks.com/topic/155156-virtualhost-redirect/#findComment-816335 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.