How to redirect www to non-www? e.g redirect www.example.com to example.com
Thanks
Johnny
How to redirect www to non-www? e.g redirect www.example.com to example.com
Thanks
Johnny
If you use Apache as a web server, there are plenty of .htaccess tricks to do just that. Google around a bit.
Aleksey
Here is a virtual host definition for apache that does the other way around, I am sure it you could adjust it for what you want. Bear in mind you will need mod_rewrite available on your server. If you do not have your own server then you usually have to implement this in the .htaccess file as explained by Aleksey <VirtualHost *:80> ServerName www.example.co.uk ServerAlias example.co.uk
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.co\.uk [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) http://www.example.co.uk/$1 [L,R]
RailsEnv production RailsBaseURI /
<Directory /srv/www/vhosts/example/current/public> Options FollowSymLinks AllowOverride None Order allow,deny Allow from All </Directory>
DocumentRoot /srv/www/vhosts/example/current/public
ErrorLog /var/log/apache2/example_production_error_log TransferLog /var/log/apache2/example_production_access_log LogLevel warn </VirtualHost>
Hope that helps.
O.
RewriteEngine on RewriteCond %{HTTP_HOST} ^www.domain.com$ RewriteRule (.*)$ http://example.com/$1
You can use this rack for your app: