在使用重写规则从url中删除.php之后,css和img文件的大小为404
我的网站和nginx服务器有问题。。。。。 从url地址中删除.php后,我在每个图像和css文件404上都有错误 这是我的整个配置文件:在使用重写规则从url中删除.php之后,css和img文件的大小为404,php,css,.htaccess,nginx,Php,Css,.htaccess,Nginx,我的网站和nginx服务器有问题。。。。。 从url地址中删除.php后,我在每个图像和css文件404上都有错误 这是我的整个配置文件: server { listen 80; server_name example.com; return 301 $scheme://www.example.com$request_uri; } server { listen 80; root /usr/sha
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 ~ \.(css|js|png|jpe?g|gif) {
# empty
}