2016-06-23 7 views
0

私はLaravel 5.1でウェブサイトをセットアップしました。ホームページを除くすべてのページに404エラーが表示されます。しかし、URLにindex.phpを追加すると、それが動作します。私のサイトはUbuntuマシン上でNginxをWebサーバーとして実行します。細かいLaravel 5.1はホームページを除いて404が見つかりません

ロード: mysite.com/index.php/dashboard

は404与える: mysite.com/dashboard

パブリックフォルダ内の私の.htaccessファイル:

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 
    RewriteBase/


    # Redirect Trailing Slashes If Not A Folder... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)/$ /$1 [L,R=301] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 

お時間をいただき、ありがとうございました。

編集:

これは私のnginxのconfにある:

サーバー{ SERVER_NAME mysite.com。 return 301 $ scheme://www.mysite.com$request_uri; }

サーバー{ listen 80; server_name www.mysite.com;

# note that these lines are originally from the "location /" block 
root /usr/share/web/site/public; 
index index.php index.html index.htm; 

    location/{ 
      try_files $uri $uri/ /index.php?$query_string; 
    } 


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

location ~ \.php$ { 
try_files $uri /index.php =404; 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 

    # fastcgi_pass 127.0.0.1:9000; 
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 

    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

    fastcgi_max_temp_file_size 0; 
    fastcgi_buffer_size 4K; 
    fastcgi_buffers 64 4k; 

    include  fastcgi_params; 
} 

} 

答えて

1

.htaccessはApache用です。 Nginxでは動作しません。

あなたのnginxのサイト構成でこれを試してみてください(Laravelのドキュメントから撮影。)

location/{ 
    try_files $uri $uri/ /index.php?$query_string; 
} 
+0

私は私のファイルであることがあります。上記を参照。 –

+0

すみません。私は本当にNginxを頻繁に使用しないので、私はあなたをさらに助けることができないと思う。 – Patrick

関連する問題