10

I've got the following .htaccess file for my apache:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks    
# Options +SymLinksIfOwnerMatch
  RewriteEngine On
  RewriteBase /
  RewriteRule ^$          index.php       [L]
  RewriteCond %{REQUEST_FILENAME}         !-f
  RewriteCond %{REQUEST_FILENAME}         !-d
  RewriteRule (.*)        index.php?page=$1  [QSA,L]
</IfModule>

Suddenly I had to change my webserver to nginx and I don't know why, but the mod rewrite is not working.

I used an online 'converter' to convert it, so I've got the following:

location / {
  rewrite ^/$ /         index.php       break;
  if ($request_filename ~         !-f){
    rewrite ^(.*)$ /       index.php?page=$1   break;
  }
}

Could you help me what's wrong?

Thanks in advance, Marcell

1
  • 4
    What idiot closed this? Updating mod rewrite rules when moving from Apache not nginx is necessary for the majority of sites. Commented Mar 16, 2014 at 10:14

2 Answers 2

19

http://web.archive.org/web/20180812021847/https://blog.martinfjordvald.com/2011/02/nginx-primer-2-from-apache-to-nginx/

Everything is inside. No more .htaccess, no more complex rules use try_files.

EDIT: And if it is not obvious, do not trust online converters.

Sign up to request clarification or add additional context in comments.

Comments

0

$ sudo vim /etc/nginx/sites-available/default

  location / {
        try_files $uri $uri/ =404;
    }

to

location / {
    try_files $uri $uri/ /index.php?$args;
}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.