0
我最近将一个使用Apache的网站移到了Nginx上。nginx - 重写php文件的url
我怎样才能得到一个URL看起来像这样:
http://example.com/login
指向http://example.com/login.php
,同时保持.PHP出来的url?
我目前的配置:
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html/;
index index.php index.html;
server_name example.com www.example.com;
location/{
try_files $uri $uri/ =404;
}
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
谢谢您的回答。在我目前的配置中......它将如何工作?我试过了,但nginx服务器没有重启。 – Ciprian