Jun 15, 2009

htAccess Magic

.Htaccess (Hypertext Access configuration file) can help you perform several important tasks.
Here are some examples:

AddDefaultCharset utf-8
What do you think this does? Eliminating your strange chars from appearing in non-latin languages.

Options +FollowSymlinks
RewriteEngine on
These are needed for the REWRITE section which is now coming.

RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule . / [R=301,L]
Instead of having both http://simania.co.il/ and http://simania.co.il/index.php you will only have one. [Why this is good is another story]

RewriteCond %{http_host} ^www.simania.co.il [nc]
RewriteRule ^(.*)$ http://simania.co.il/$1 [r=301,nc]
Instead of having both http://simania.co.il/ and http://www.simania.co.il/ you will only have one. [ same note]

RewriteCond %{http_host} ^somethingOLD.simania.co.il [nc]
RewriteRule ^(.*)$ http://simania.co.il/$1 [r=301,nc]
Old subdomain that no longer exists. Make it disappear, without loosing traffic.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} ^/(.*)/(.*)/(.*)/(.*)$
RewriteRule ^rss/([^/]*)/([^/]*)/([^/]*) /feed.php?type=$1&user=$2&item=$3 [T=application/x-httpd-php]
Have some FRIENDLY urls. From http://simania.co.il/rss/AAA/BBB/CCC you get http://simania.co.il/feed.php?type=AAA&user=BBB&item=CCC

ErrorDocument 404 /404.php
Have all the mistyped urls (and those that no longer exist) bring up your custom 404 error file.

order allow,deny
deny from 41.208.
allow from all
Block some nasty IP addresses, or allow just the ones you want.

No comments:

Post a Comment