Nginx extensionless PHP rewrite not working -
i have been trying rewrite php pages display without extensions in browser. example, link on server @ www.example.com loads page called about-us.php , in browser, user see www.example.com/about-us.
i have been trying follow these tutorials try , work, sadly not working.
here nginx sites-available/default file content.
# server block server { # listening ports listen 80 default_server; listen [::]:80 default_server ipv6only=on; # root location initialization root /home/zach/documents/workspaces/www; index index.php index.html index.htm; # server name server_name localhost; # root location location / { try_files $uri $uri/ @extensionless-php; } # error pages error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /home/zach/documents/workspaces/www; } # php handling location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } # extensionless php location @extensionless-php { rewrite ^(.*)$ $1.php last; } } all of links php pages still display .php extension in browser, have solutions problem?
add following line exact spot think it'd form loop! :-)
if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; } more info here: nginx remove .php , .html file extension
Comments
Post a Comment