Laravel将正常呈现默认/根页面。 但不会呈现默认路由或错误页面。 我的网页浏览器将返回与Apache(不Laravel)错误页与我尝试和访问/testing
这里有一些信息(请让我知道如果你需要更多的细节)
服务器目录树
/var/www/ └── html ├── access.log ├── app ├── artisan ├── bootstrap ├── composer.json ├── composer.lock ├── config ├── database ├── error.log ├── gulpfile.js ├── package.json ├── phpspec.yml ├── phpunit.xml ├── public ├── readme.md ├── resources ├── server.php ├── storage ├── tests └── vendor
视图(testing视图是默认欢迎视图的副本)
/var/www/html/resources/views/ ├── errors │ └── 503.blade.php ├── test.blade.php ├── vendor └── welcome.blade.php
路线
<?php Route::get('/', function () { return view('welcome'); }); Route::get('test', function () { return view('test'); }); Route::get('anotherTest', function () { return 'Hello World'; });
Apacheconfiguration
<VirtualHost *:80> # The location of our projects public directory. DocumentRoot /var/www/html/public # Useful logs for debug. CustomLog /var/www/html/access.log common ErrorLog /var/www/html/error.log # Rewrites for pretty URLs, better not to rely on .htaccess. <Directory /www/var/html> <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </Directory> </VirtualHost>
使用默认(提供).htaacess文件
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # 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>
另外我的错误日志是空的但访问日志显示404和496
admini@linux:/var/www/html$ cat error.log admini@linux:/var/www/html$ cat access.log 192.168.1.130 - - [24/Jul/2015:15:51:53 -0700] "GET / HTTP/1.1" 200 1448 192.168.1.130 - - [24/Jul/2015:15:54:46 -0700] "GET /test HTTP/1.1" 404 496 192.168.1.130 - - [24/Jul/2015:15:56:37 -0700] "GET /test HTTP/1.1" 404 496 192.168.1.130 - - [24/Jul/2015:15:57:11 -0700] "GET /test HTTP/1.1" 404 496 192.168.1.130 - - [24/Jul/2015:15:57:13 -0700] "GET /test HTTP/1.1" 404 495 192.168.1.130 - - [24/Jul/2015:16:14:53 -0700] "GET /test HTTP/1.1" 404 496 192.168.1.130 - - [24/Jul/2015:16:14:53 -0700] "GET /test HTTP/1.1" 404 495 192.168.1.130 - - [24/Jul/2015:16:18:16 -0700] "GET /test HTTP/1.1" 404 496 192.168.1.130 - - [24/Jul/2015:16:18:17 -0700] "GET /test HTTP/1.1" 404 495 admini@linux:/var/www/html$
改变我的Apacheconfiguration文件到下面解决了这个问题。
<VirtualHost *:80> ServerName somehost DocumentRoot /var/www/html/public CustomLog /var/www/html/access.log common ErrorLog /var/www/html/error.log <Directory /var/www/html/public> <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </Directory> </VirtualHost>