无法从laravel url中删除index.php?在Ubuntu 14.04
there 我刚刚在laravel 5.2中创建了一个新项目。那么我已经成功地从我的项目的网址中删除public/index.php
在Windows中工作正常。 但是,当我在var/www/html里的ubuntu里拷贝同样的项目为/var/www/html/myproject
。并启用apache2 rewrite_mode。但是,如果不将index.php放入网址中,它就无法工作。它的工作只有公共而已。 http:://localhost/myproject/index.php/cms
(正常工作),但 http:://localhost/myproject/cms
(它不工作)???任何建议? 我的代码是无法从laravel url中删除index.php?在Ubuntu 14.04
route.php
define("PREFIX", "cms");
Route::get(PREFIX . '/login', 'Auth\[email protected]');
它精细 还我已经削减公共文件夹中的所有文件复制到根目录下,编辑index.php文件作为
require __DIR__.'/../bootstrap/autoload.php';
通过
require __DIR__.'/bootstrap/autoload.php';
和
$app = require_once __DIR__.'/../bootstrap/app.php';
通过
$app = require_once __DIR__.'/bootstrap/app.php';
htaccess的作为
<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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
我就遇到了这个和foud上http://laravel.io的溶液。
如果你使用Apache 2.4.7 apache2.conf被设置为不允许.htaccess覆盖设置了AllowOverride无:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
您可以在apache2.conf改变这一状况,但不建议这样做。相反,这是否覆盖VirtualHosts文件为您的网站ie。网站可用/ yoursite.com.conf。类似这样的:
<Directory /var/www/html/yoursite.com/laravelappinstall/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
请确保您已启用重写模块即。 sudo a2enmod重写。重新启动您的Web服务器即。 sudo服务apache2重启。
来源:http://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116
是的,我感谢您的帮助。解决了 –
太好了。如果您有机会,请检查此解决方案。谢谢! –
•转到mainproject /公共>>
a. .htacess
b. favicon.ico
c. index.php
d. robots.txt
e. web.config
1.cut从公用文件夹这5个文件,然后在这是最主要的项目文件夹中粘贴意味着从公众的侧文件夹... mainproject /文件粘贴,开放的index.php后
2.Next,修改
•require __DIR__.'/…/bootstrap/autoload.php'; to
•require __DIR__.'/bootstrap/autoload.php';
modify
$app = require_once DIR.'/../bootstrap/app.php'; to
$app = require_once DIR.'/bootstrap/app.php';
似乎没有加载mod_rewrite,或者'AllowOverride All'不在httpd.conf中,所以.htaccess文件被忽略。确保为您的虚拟主机或默认主机配置设置[AllowOverride](http://httpd.apache.org/docs/current/mod/core.html#AllowOverride)。 – drew010
谢谢。它解决了! –