My Nginx conf file :
location / {
try_files $uri $uri/ /index.php?url=$uri;
}
## PHP conf in case it's relevant
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include /etc/nginx/fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Trying the following URL : http://example.org/login
:
expected behavior :
http://example.org/index.php?url=login
actual behavior :
http://example.org/index.php?url=/login
Use a named location and an internal rewrite. For example:
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?url=$1 last;
}
See this document for more.
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