Forum Moderators: phranque
# Engine
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
# Hotlinking
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|bmp|ico|swf)$ [NC]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?example\. [NC] [OR]
RewriteCond %{HTTP_REFERER} !^https?://([^.]+\.)?example2\. [NC]
RewriteRule \.(gif|jpe?g?|png|bmp|ico|swf)$ - [F,NC,L]
########## Remove duplicate trailing slashes if exist
##########RewriteRule (.*)/$ $1 [L,R=301]
# Add trailing slash
##########RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ /$0/ [L,R=301]
#HTTPS to HTTP
#RewriteCond %{HTTPS} on [OR]
#RewriteCond %{SERVER_PORT} 443
#RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301,L]
# No 'www'
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Root redirect exclusions
# Domain exclusions
##########RewriteCond %{REQUEST_URI} !^/(example2).*$ [OR]
##########RewriteCond %{HTTP_HOST} !^(www\.)?(example2)\.?(co\.za)
##########RewriteCond %{HTTP_HOST} ^(www\.)?example2.co.za$
RewriteRule .* - [S=3]
# Page exclusions
RewriteCond $1 !^samplepage\.php$
RewriteCond $1 !^robots\.txt$
# Root redirect
RewriteRule (.*) http://mrally.example.com/$1 [R=301,L] [edited by: jdMorgan at 3:12 pm (utc) on May 31, 2010]
[edit reason] example.com [/edit]
RewriteCond %{HTTP_HOST} !example2 [NC] <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Subdomain folder redirects
RewriteCond %{HTTP_HOST} !^example2\.example\.com
RewriteRule (.*) http://example2.co.za/$1 [R=301,L]
</IfModule> [edited by: jdMorgan at 3:14 pm (utc) on May 31, 2010]
[edit reason] example.com [/edit]
# Root redirect exclusions
# Domain exclusions
RewriteCond %{HTTP_HOST} ^(www\.)?example2.co.za
RewriteRule .* - [S=3]
# Page exclusions
RewriteCond $1 !^sample\.php$
RewriteCond $1 !^robots\.txt$
# Root redirect
RewriteRule (.*) http://mrally.example.com/$1 [R=301,L] # Engine
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !www\.example2\.co\.za
RewriteRule (.*) "http\:\/\/www\.example2\.co\.za\/" [R=301,L] [edited by: jdMorgan at 3:14 pm (utc) on May 31, 2010]
[edit reason] example.com [/edit]
# Root redirect exclusions
# Skip next three rules for "example2.co.za" and "www.example.2.co.za" requests
RewriteCond %{HTTP_HOST} ^(www\.)?example2.co.za
RewriteRule ^ - [S=3]
#
# Exclude sample.php and robots.txt from redirect to mrally.example.com
RewriteCond $1 !^(sample\.php|robots.txt)$
# Externally redirect all other requests for hostnames other than "example2.co.za"
# and "www.example2.co.za" to "mrally.example.com"
RewriteRule ^(.*)$ http://mrally.example.com/$1 [R=301,L]
# Enable mod_rewrite rewriting engine
RewriteEngine on
#
# Set RewriteBase back to default from previously-set
# non-default setting ([b]is this really required?[/b])
RewriteBase /
#
# Redirect all non-blank non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.example2\.co\.za)?$
RewriteRule ^(.*)$ http://www.example2.co.za/ [R=301,L]
RewriteCond $1 !^(sample\.php|robots.txt)$
RewriteRule ^(.*)$ http://mrally.example.com/$1 [R=301,L] [edited by: jdMorgan at 5:04 pm (utc) on May 31, 2010]
[edit reason] de-linked [/edit]
# Root redirect exclusions
# Skip next three rules for "example2.co.za" and "www.example.2.co.za" requests
RewriteCond %{HTTP_HOST} ^(www\.)?example2\.co\.za
[b]RewriteRule ^ - [S=1][/b]
#
# Exclude sample.php and robots.txt from redirect to mrally.example.com
RewriteCond $1 !^(sample\.php|robots\.txt)$
# Externally redirect all other requests for hostnames other than "example2.co.za"
# and "www.example2.co.za" to "mrally.example.com"
RewriteRule ^(.*)$ http://mrally.example.com/$1 [R=301,L]
# Exclude hostnames "example2.co.za" and "www.example2.co.za" and blank
RewriteCond %{HTTP_HOST} !^((www\.)?example2\.co\.za\.?(:[0-9]+)?)?$
# Exclude sample.php and robots.txt
RewriteCond $1 !^(sample\.php|robots\.txt)$
# Externally redirect all other requests to "mrally.example.com"
RewriteRule ^(.*)$ http://mrally.example.com/$1 [R=301,L]