2

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;

}

Thanks!

1
  • is the reqrite a typo or is it what you are trying? It should be rewrite. Jan 26, 2016 at 20:03

1 Answer 1

2

Try:

location / {
    rewrite ^(.*)$ /index.php last;
}
5
  • Still '500 Internal Server Error'. :-( Jan 24, 2011 at 0:45
  • try with break.
    – osdyng
    Jan 24, 2011 at 2:49
  • 1
    when i try adding this it outputs my php source into the browser ! ... Jan 17, 2013 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
    Oct 4, 2013 at 19:50
  • It should be last instead of break to allow the php location to still redirect the code to the php (f)cgi. Jan 26, 2016 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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