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
Since Nginx does not have an equivalent to the . htaccess file (i.e. no directory level configuration files), you need to update the main configuration and reload nginx for any changes to take effect.
Nginx does not use . htaccess files like Apache does. This means that configuration previously done in . htaccess files now has to be done in a different format, explained in the Nginx documentation.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With