我试过这个:http://www.tweaktalk.net/60/nginx-remove-php-file-extension-from-url,但它对我不太有用。我收到错误 404 或错误 505
我正在使用带有nginx服务器的数字海洋托管。
如果有人想知道我是如何解决这个问题的:
我去了目录/etc/nginx/conf.d,在那里创建了一个名为"domain.trade.conf">的文件夹,例如,如果我的域是 example.com,文件夹名称将是example.com.conf。
在此文件中,我添加了以下代码:
server {
listen 80;
server_name example.com; #Domain
root /var/www/html; #The place of your site files
access_log /var/www/html/logs/access.log; #Where to log the accesses
error_log /var/www/html/logs/error.log; #Where to log the errors
location / {
try_files $uri $uri/ @htmlext;
}
location ~ .html$ {
try_files $uri =404;
}
location @htmlext {
rewrite ^(.*)$ $1.html last;
}
}
希望我能帮到你。