Welcome! Log In Create A New Profile

Advanced

Help with nginx configuration

Posted by saharAti 
Help with nginx configuration
July 20, 2015 03:01PM
Hey eveyone,
I have the following server block:

server {
listen 80;
server_name www.petpal.co.il;
return 301 http://petpal.co.il$request_uri;
}
server {
listen 80;
server_name petpal.co.il;
root /usr/share/nginx/petpal;
index index.php;
location / {
try_files $uri $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
error_page 404 /notfound;
location ~ \.php$ {
try_files $uri /notfound;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

What modifications do I have to make to it in order to:
* redirect users that try to access files with .php extension to the file without the extenstion, for example dogs.php to dogs (for SEO purposes, the execution proccess already exist).
* Make it so the 404 document will be displayed according to the directory the user is currently in, for example in directory "/en" it would display /en/notfound, in directory "/" it would display "/notfound"...
* Change pages with query strings syntax for example: article?id=1 to article-1

Thanks to the helpers
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 142
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready