I have been using .htaccess and would recently want to convert to Nginx rewrite as for the url as well, but unfortunately I can’t seem to get it to work. I am currently testing it locally in Laragon using Nginx and this is what I have from the configuration file:
server {
listen 8080;
server_name bsl.test *.bsl.test;
root "D:/laragon/www/bsl";
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
autoindex on;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass php_upstream;
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ /.ht {
deny all;
}
}
Below is what I have in .htaccess
#START Modules
RewriteRule ^modules/?$ modules.php?type=modules [L]
#END Modules
#START User Management
RewriteRule ^user/?$ user.php?type=user [L]
RewriteRule ^user/([^/.]+)/?$ user.php?type=user&action=$1 [L]
RewriteRule ^user/([^/.]+)/([^/.]+)/?$ user.php?type=user&action=$1&id=$2 [L]
#END User Management
#START User Rights Management
RewriteRule ^user-rights/?$ user.php?type=user-rights [L]
RewriteRule ^user-rights/([^/.]+)/?$ user.php?type=user-rights&action=$1 [L]
RewriteRule ^user-rights/([^/.]+)/([^/.]+)/?$ user.php?type=user-rights&action=$1&id=$2 [L]
#END User Rights Management
Please help as I am current stucked.
Thank you