[英]unable to remove index.php from laravel url ?? in ubuntu 14.04
there I just created a new project in laravel 5.2. 在那里,我刚刚在laravel 5.2中创建了一个新项目。 then I had successfully removed
public/index.php
from url of my project in windows it works fine. 那么我已经在Windows中从项目的URL成功删除了
public/index.php
,它工作正常。 But While I copied the same project in ubuntu inside var/www/html as /var/www/html/myproject
. 但是,虽然我在var / www / html中的ubuntu中复制了与
/var/www/html/myproject
相同的项目。 And enabled apache2 rewrite_mode. 并启用apache2 rewrite_mode。 But it no work without putting index.php in url.
但是,如果不将index.php放在url中,那就没有用。 It works without public only.
它仅在不公开的情况下有效。
http:://localhost/myproject/index.php/cms
(it works fine) BUT http:://localhost/myproject/cms
(it does not works)??? http:://localhost/myproject/index.php/cms
(工作正常)但http:://localhost/myproject/cms
(无效)??? .Any suggestion???? 有什么建议吗???? my code is as
我的代码是
route.php route.php
define( "PREFIX", "cms" );
Route::get(PREFIX . '/login', 'Auth\AuthController@getLogin');
it fine also I already cut all files from public folder to root directory and edit index.php file as 也很好,我已经将所有文件从公用文件夹剪切到根目录并编辑index.php文件为
require __DIR__.'/../bootstrap/autoload.php';
By 通过
require __DIR__.'/bootstrap/autoload.php';
and 和
$app = require_once __DIR__.'/../bootstrap/app.php';
by 通过
$app = require_once __DIR__.'/bootstrap/app.php';
.htaccess as .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>
I ran into this and foud a solution on http://laravel.io . 我遇到了这个问题,并在http://laravel.io上找到了解决方案。
On Apache 2.4.7 the apache2.conf is set to not allow .htaccess override by setting AllowOverride None: 在Apache 2.4.7上,通过设置AllowOverride None来将apache2.conf设置为不允许.htaccess覆盖:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
You can change this in apache2.conf, but this is not recommended. 您可以在apache2.conf中更改它,但是不建议这样做。 Instead do this override in the VirtualHosts file for your site ie.
而是在您网站的VirtualHosts文件中执行此覆盖,即。 sites-available/yoursite.com.conf.
网站可用/ yoursite.com.conf。 Something like this:
像这样:
<Directory /var/www/html/yoursite.com/laravelappinstall/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Make sure that you have enabled the rewrite module ie. 确保已启用重写模块,即。 sudo a2enmod rewrite.
sudo a2enmod重写。 Restart your web server ie.
重新启动您的Web服务器。 sudo service apache2 restart.
sudo服务apache2重新启动。
Source: http://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116 来源: http : //laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116
•Go to mainproject/public>> •转到主项目/公共>>
a. .htacess
b. favicon.ico
c. index.php
d. robots.txt
e. web.config
1.cut these 5 files from public folder,and then paste on the main project folder that's means out side of public folder… mainproject/files 1.从公共文件夹中剪切这五个文件,然后粘贴到主项目文件夹中,这意味着公共文件夹的外面…mainproject / files
2.Next after paste ,open index.php ,modify 2.下一步粘贴后,打开index.php,修改
•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';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.