alienhelpdesk.com

htaccess

This is a very basic .htaccess file as I like to use it. It simply redirects any request to the index.php if it's not an existing file and not an existing directory.

<IfModule mod_rewrite.c>
 
RewriteEngine On 
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/? /index.php?loc=$1
 
</IfModule>

It works as follows:

checks to see if mod-rewrite is enabled

You can add Options +FollowSymlinks on the line before RewriteEngine On
It needs to be enabled for mod rewrite to actually work

RewriteEngine On
Start the rewrite engine

RewriteCond %{REQUEST_FILENAME} !-f
Is a condition and returns true if the requested location is not an existing file.

RewriteCond %{REQUEST_FILENAME} !-d
Is a condition and returns true if the location is not an existing directory.

RewriteRule ^(.*)/? /index.php?loc=$1
Does the actual redirection, basicly it takes everything from behind http://www.mysite.domain/ and puts it behind loc=
So inside your index.php you can get the url as $_GET['loc']
You can then use PHP to analyse what was requested.



The end of the rewriting.

There are lots of more complicated things you can do, but this is what I need more often and it does only the thing I need... which is good.


projects
Project London
The latest movie directed by Ian Hubert! And I get to help!
Swedish proverb
När man talar om trollen så står de i farstun och lyssnar
When you´re speaking about the trolls, they´re standing in the entrance hall and listen
BLENDER BOY!
BLENDER BOY!
T-shirts!
usefull sites
blender.org
Home of the blender foundation