|
|
|
This is the .htaccess for currawong.net. I think the order of items is wrong though - but it works, so i don't care
Some of the regexp is a bit lazy, so be warned! I buggered around with the file for ages adding and removing all sorts of bits over time or trying things different ways. Anyone reading it and cringing note that it was far worse than this before!
# The IfModule bit isn't needed really, what webserver doesn't have it?
<IfModule>
# Turn re-writing on - duh
RewriteEngine On
# Redirects / to macdash and ignore further rules. [L] = last
RewriteRule ^$ http://macdash.com/cnet/ [R,L]
# Redirects all other requests to macdash and ignore further rules
# If the request isn't "!" a file "-f" or directory "-d" then
# rewrite the part of the request "(.+)" from the beginning of the request "^"
# to that same request "$1" at http://macdash.com/cnet/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) http://macdash.com/cnet/$1 [R,L]
# Hotlink prevention for images and movies, unless they are hotlinked from
# the 3 sites mentioned. [F] = Fail (or maybe F*** off)
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?currawong.net/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?appletalk.com.au/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*\.)?macdash.com/.*$ [NC]
RewriteRule \.(gif|jpg|mov|mpg|wmv|avi|mp3)$ - [F]
# Request for currawong.net/<anything>/ tries for a static page if the directory doesn't exist (!-d).
# Note that this is a reference to Geeklog's static page system. I set this up
# because I used to have subdirectories for certain sections on the site that
# I moved to Geeklog's static pages module instead. I used QSA (Query String
# Append) here so that the url accessed doesn't change, even though it's
# loading a different url. Also, it doesn't work if the url requested contains
# a "." or a "?" as the request would then be for a file or php page.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)/$ /s/index.php?page=$1 [QSA]
</IfModule>
# Prevent anyone getting an index of files by showing nothing in empty directories.
IndexIgnore .*
# This SHOULD be instead:
# Options -Indexes
# and IndexIgnore should be used for individual file types
# Basic redirects
Redirect permanent /nazirene http://nazirene.currawong.net
Redirect permanent /scripts http://scripts.currawong.net
# Redirectmatch is cooler, as you can use regexp. Really, it's not
# any different to ReWrite except that it gives a redirect code back
# to the browser, and to the web logs.
# I decided for Themer to use a text page instead of a static page
# in the Geeklog, so the first one is commented out.
# RedirectMatch permanent ^/aquaworld/(.*)\.(sit|zip|dmg)$ http://currawong.net/s/index.php?page=themer
RedirectMatch permanent ^/aquaworld/(.*)\.(sit|zip|dmg)$ http://currawong.net/themer.txt
# These are similar to the rewrites above, but I don't use them.
# RedirectMatch /(.*) http://macdash.com/cnet/$1
# RedirectMatch /(gallery|gallery/)? http://macdash.com/cnet/$1 |
|