2

I have problem with my website and nginx server..... After remove .php from my url adress I have errors on every image and css files 404.

There is my whole config file :

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;
    }

}

Thanks for every opinion!! Regards Makromat

4

1 に答える 1

2

php書き換えを拡張子のない URI のみに制限してみてください。

rewrite ^([^\.]*)$ /$1.php;

location /または、最初のブロックの前にこのブロックを追加して、画像を完全に除外できます。

location ~ \.(css|js|png|jpe?g|gif) { 
    # empty
}
于 2013-11-14T18:49:58.843 に答える