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'm new to Nginx, how can I rewrite this mod_rewrite, so that will work in Nginx?

RewriteEngine On
RewriteRule (.*) index.php

I tried this, but it didn't work.

location / {


    reqrite (.*) /index.php last;



share|improve this question
is the reqrite a typo or is it what you are trying? It should be rewrite. – white_gecko Jan 26 at 20:03
up vote 2 down vote accepted


location / {
    rewrite ^(.*)$ /index.php last;
share|improve this answer
Still '500 Internal Server Error'. :-( – Laura Brown Jan 24 '11 at 0:45
try with break. – osdyng Jan 24 '11 at 2:49
It works, thanks! – Laura Brown Jan 24 '11 at 7:23
when i try adding this it outputs my php source into the browser ! ... – Hayden Thring Jan 17 '13 at 10:53
@HaydenThring That's probably because you are not executing the PHP, you also will need to have it configured to actually execute the PHP. – Bjorn Tipling Oct 4 '13 at 19:50

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.