我对Laravel有问题.在要运行Debian 8.5的名为fmbsrv130的Apache 2.4.10 Web服务器上,我想安装一个名为sentinelle的Laravel项目.
I have an issue with Laravel. On an intranet Apache 2.4.10 Webserver runing with Debian 8.5, named fmbsrv130, I would like to install a Laravel Project named sentinelle.
Laravel安装正常,我可以使用 fmbsrv130/sentinelle/(我有Laravel的欢迎页面).但是,如果我尝试转到 fmbsrv130/sentinelle/1 (不存在),在Apache2中有404,显示在此服务器上找不到所请求的URL/home/webadmin/sentinelle/public/index.php".如果我尝试访问 fmbsrv130/sentinelle/index.php/1 Laravel的404:很抱歉,找不到您要查找的页面.RouteCollection.php第161行中的1/1 NotFoundHttpException:..."
So Laravel installation is OK, I can access to it with fmbsrv130/sentinelle/ (I have the welcome page of Laravel). But if I try to go to fmbsrv130/sentinelle/1 (that does not exists), I have 404 from Apache2 that says "The requested URL /home/webadmin/sentinelle/public/index.php was not found on this server." If I try to access fmbsrv130/sentinelle/index.php/1 I have the 404 from Laravel : "Sorry, the page you are looking for could not be found. 1/1 NotFoundHttpException in RouteCollection.php line 161: ..."
rewrite_mod已在Apache中正确启用.
rewrite_mod is correctly enabled in Apache.
这是Apache的配置文件(站点可用的000-default.conf):
Here is config file of Apache (000-default.conf in sites-available) :
Alias "/sentinelle" "/home/webadmin/sentinelle/public/" <Directory "/home/webadmin/sentinelle/public/"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>为了进行测试,如果我尝试使用
For testing, if I try to modify .htaccess file from public folder of Laravel with
RewriteEngine On RewriteRule ^.*$ htaccess_tester.php(htaccess_tester.php是用于测试.htaccessfile内容的文件(在GitHub上查看),当前位于公共文件夹中),我有Apache2 404错误消息所请求的URL/home/webadmin/在此服务器上未找到sentinelle/public/htaccess_tester.php.
(htaccess_tester.php is a file that is used to test content of .htaccessfile (see it on GitHub) and is currently into public folder), I have Apache2 404 error message The requested URL /home/webadmin/sentinelle/public/htaccess_tester.php was not found on this server.
是.htaccess文件问题还是Apache2配置问题还是Laravel配置问题或文件访问权限?
Is it an issue from .htaccess file OR an issue from Apache2 config OR an issue from Laravel config OR a file access right ?
推荐答案好,最后我通过做一些修改找到了一个解决方案:第一个是将.htaccess文件放入公用文件夹:
OK so finally I found a solution by doing some modifications : first one is .htaccess file into public folder:
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On RewriteBase /sentinelle/ # 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] # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </IfModule>(添加RewriteBase/sentinelle/)
(Adding RewriteBase /sentinelle/)
第二个是进入default.conf Apache文件:
And the second one was into default.conf Apache file :
Alias /sentinelle /home/webadmin/sentinelle/public/ <Directory "/home/webadmin/sentinelle/public"> AllowOverride All Order allow,deny allow from all Require all granted </Directory>它解决了本主题中描述的问题,我将打开另一个,因为现在我的地址中有最后一个"/" :)
It solved the issue described into this topic, I'll open another one because now I have issue with last "/" in address :)
更多推荐
Laravel和Apache2:无法正确使用重定向
发布评论