3

CentOS 6.4 と NginX 1.8 を実行している VPS で Laravel フレームワークをセットアップしようとしています。「website.com/index.php/home」の代わりに「website.com/home」を使用するなど、よりクリーンな URL を機能させることができないことを除いて、他のすべてを完全に機能させることができます。誰でも助けることができますか?これは現在、私の仮想ホスト構成ファイルの内容です。

server {

    listen 80;
    server_name swati.havok.semicolony.com;
    access_log /usr/share/nginx/semicolony.com/_subdomains/swati/storage/logs/access.log;
    error_log /usr/share/nginx/semicolony.com/_subdomains/swati/storage/logs/errors.log;

    root /usr/share/nginx/semicolony.com/_subdomains/swati/public;
    index index.php;

    #browse folders if no index file
    autoindex on;

    # enforce NO www
    if ($host ~* ^www\.(.*))
    {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }

    # serve static files directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        #expires max;
    }

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~ \.php$ {
    root                    /usr/share/nginx/semicolony.com/_subdomains/swati/public;
    fastcgi_pass            127.0.0.1:9000;
    fastcgi_index           index.php;
    fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include             fastcgi_params;
    }

    location ~ /\.ht {
        deny  all;
    }
}

編集:Laravel 4を使用していることは重要かもしれません.

4

2 に答える 2

5

私は Nginx にあまり詳しくありませんが、書き直しの正規表現が間違っていると思います。

変更してみる

rewrite ^/(.*)$ /index.php?/$1 last;

に:

rewrite ^/(.*)$ /index.php/$1 last;

または:

rewrite ^.*$ /index.php last;

于 2013-04-07T22:02:21.047 に答える