我的网站和Nginx服务器有问题.....从我的网址地址中删除.php后,我在每个图像和CSS文件404上都有错误。
这是我的整个配置文件:
server {
listen 80;
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
server {
listen 80;
root /usr/share/nginx/www;
index index.php;
server_name www.example.com;
error_page 404 http://www.example.com/404.php;
autoindex off;
error_log /usr/share/nginx/www/nginx_error.log warn;
location / {
rewrite ^(.*)$ /$1.php;
}
location = / {
rewrite ^ /index.php;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
谢谢大家的意见!!问候Makromat
尝试将php
重写限制为仅带扩展名的URI:
rewrite ^([^\.]*)$ /$1.php;
或者您可以通过在第一个location /
块之前添加以下块来完全排除图像:
location ~ \.(css|js|png|jpe?g|gif) {
# empty
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句