views:

13

answers:

1

I am trying to redirect all traffic through index.php.

Here is my .htaccess file:

RewriteEngine On

RewriteRule ^(.*)$ /index.php?ref=$1 [NC,L]

I'm always getting HTTP 500 errors, and I check the error.log and I see that its the internal recursion error. Can anyone help me with this? Thanks.

+2  A: 

Not entirely sure whether this is the canonical way to do this, but adding a condition like this will work:

RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php?ref=$1 [QSA]

(The QSA to add any query strings.)

However, I would recommend an additional

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

to prevent static resources from being sent through your index.php (unless that is really what you want.)

Pekka
Wrikken