Forum Moderators: phranque
RewriteEngine on
Options +FollowSymlinks
#This stops everybody from using my images except list below
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example-two.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?got-example.net(/)?.*$ [NC]
RewriteRule \.(gif|jpg|js|css|png)$ - [F,NC,L]
#
#This blocks bad bots and site rippers
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
#etc etc...
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
#
#Prevent people from reading this htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
#
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
#
Redirect 301 /why-use-a-pet-sitter http://www.example.com/got-example/why-pet-sitting.php
Redirect 301 /services-and-rates http://www.example.com/got-example/services.php
Redirect 301 /rates http://www.example.com/got-example/rates.php
Redirect 301 /about-us http://www.example.com/got-example/about-us.php
Redirect 301 /contact-us http://www.example.com/got-example/contact-us.php
Redirect 301 /my-critters http://www.example.com/got-example/my-critters.php
Redirect 301 /references http://www.example.com/got-example/testimonials.php
Redirect 301 /favorite-links http://www.example.com/got-example/links.php
#
#Below makes everything www. version
RewriteCond %{HTTP_HOST} (.*)got-example\.net [NC,OR]
RewriteCond %{HTTP_HOST} (.*)example-two\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^/?example\.com [NC]
RewriteRule .? http://www.example.com/got-example/index.php [L,R=301] [edited by: jdMorgan at 10:51 pm (utc) on Feb. 3, 2010]
[edit reason] examplified. Please see TOS and Charter. [/edit]
#Below makes everything www. version
RewriteCond %{HTTP_HOST} (.*)got-example\.net [NC,OR]
RewriteCond %{HTTP_HOST} (.*)example-two\.com [NC]
RewriteRule .? http://www.example.com/got-example/index.php [L,R=301]
#
RewriteCond %{REQUEST_URI} !^/got-example/index.php$ [NC]
RewriteCond %{HTTP_HOST} ^www\.example.com(/)?$ [NC]
RewriteRule .? http://www.example.com/got-example/index.php [L,R=301] [edited by: jdMorgan at 10:54 pm (utc) on Feb. 3, 2010]
[edit reason] Examplified. Please see TOS and Charter. [/edit]
# Redirect all non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^([^.]+\.)*(example\.com|example-two\.com|got-example\.net)
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
# Internally rewrite all 'page' requests to index.php script
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|ico|css|js|txt|pdf|xml)$
RewriteCond %{REQUEST_URI} !^/got-example/index.php$
RewriteRule ^ /got-example/index.php [L]