Forum Moderators: phranque
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule ^ - [F]
#
# Define canonical hostname (add "www" if it is missing)
RewriteCond www.%{HTTP_HOST} ^(www\.)?(www\.[a-z-]+\.[a-z]{2,6})\.?(:[0-9]+)?$ [NC]
RewriteRule ^ - [E=MyHostName:%2]
#
# Externally redirect to add missing trailing slash to requested
# URLs containing no period in the final URL-path-part
RewriteRule ^(([^/]+/)*[^.]*[^./])$ http://%{ENV:MyHostName}/$1/ [R=301,L]
#
# Externally redirect to canonical "www" subdomains
RewriteCond %{HTTP_HOST} !^(www\.[a-z-]+\.[a-z]{2,6}\.?(:[0-9]+)?)?$ [NC]
RewriteRule ^(.*)$ http://%{ENV:MyHostName}/$1 [R=301,L]
#
ErrorDocument 404 /404.php
# Stop mod_rewrite processing if "es" subdomain requested
RewriteCond %{HTTP_HOST} ^es\.mydomain.com
RewriteRule .* - [L]
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule ^ - [F]
#
# Define canonical hostname (add "www" if it is missing)
RewriteCond www.%{HTTP_HOST} ^(www\.)?(www\.[a-z-]+\.[a-z]{2,6})\.?(:[0-9]+)?$ [NC]
RewriteRule ^ - [E=MyHostName:%2]
#
# Externally redirect to canonical "www" subdomains
RewriteCond %{HTTP_HOST} !^(www\.[a-z-]+\.[a-z]{2,6}\.?(:[0-9]+)?)?$ [NC]
RewriteRule ^(.*)$ http://%{ENV:MyHostName}/$1 [R=301,L]
#
ErrorDocument 404 /404.php