Created
September 14, 2013 10:51
-
-
Save blastseld/6561007 to your computer and use it in GitHub Desktop.
Apache 301 SEO redirect of domain, subdomain, tld, naked domain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of working basic configuration | |
<VirtualHost *:80> | |
ServerAdmin webmaster@localhost | |
ServerName www.villapiaeventi.it | |
DocumentRoot /var/www/villapiaeventi.it | |
<Directory /> | |
Options FollowSymLinks | |
AllowOverride All | |
</Directory> | |
<Directory /var/www/villapiaeventi.it> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride All | |
Order allow,deny | |
allow from all | |
</Directory> | |
</VirtualHost> | |
# Specific redirect, only one hop, no chained 301 redirect | |
<VirtualHost *:80> | |
ServerName villapiaeventi.it | |
ServerAlias *.villapiaeventi.it villapiaeventi.com *.villapiaeventi.com | |
RedirectPermanent / http://www.villapiaeventi.it/ | |
</VirtualHost> | |
# General redirect for naked domain | |
<VirtualHost *:80> | |
ServerName default | |
ServerAlias * | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
# WITH 'www.' | |
RewriteCond %{HTTP_HOST} !^www.(.*) [nocase] | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [redirect=permanent,nocase,last] | |
</IfModule> | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment