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