Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want to convert a nginx rewriterule to a htaccess rewrite rule.

The nginx one is the following:

rewrite ^/(.*)$ /index.php?$1 last;

I tried it with:

RewriteEngine On
RewriteRule ^/(.*)$ /index.php?$1

... but i doesnt work correctly. (No Page found)

It would be nice if anyone can help me.


I changed the suggestion from "Logic Wreck" a little bit (because it was not possible to change the index.php to another):

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

and it works great :).

share|improve this question
append a last|L flag, then try again. – quanta Aug 22 '12 at 14:00

Try these:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.