从Laravel url中删除/public/index.php
我对拉威尔很陌生。我尝试了以下解决方案从Laravel url中删除“.public/index.php” 我有一个htaccess文件在根目录下,另一个在公用文件夹中 在我写的根文件中从Laravel url中删除/public/index.php,php,.htaccess,laravel-4,Php,.htaccess,Laravel 4,我对拉威尔很陌生。我尝试了以下解决方案从Laravel url中删除“.public/index.php” 我有一个htaccess文件在根目录下,另一个在公用文件夹中 在我写的根文件中 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] </IfModule> 重新启动发动机 重写cond%{REQ
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
重新启动发动机
重写cond%{REQUEST_URI}^公众的
重写规则^(.*)$public/$1[L]
在公用文件夹的htaccess文件中我写了
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
选项-多视图
重新启动发动机
#重定向尾部斜杠。。。
重写规则^(.*)/$/$1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
但什么都没用
它仍然会打开laravel中的目录列表
我只想将我的url
www.abc.com/public/index.php
转换为www.abc.com/
,而无需将文件从公用文件夹删除到其他文件夹类型的解决方案。在Apache配置中,将文档根目录设置为/yourapp/public
——这意味着是根web可访问的文件夹;如果webroot不是Laravel的public
文件夹,那么您可能不想访问它。您只需修复站点.conf
文件中的文档根目录和目录覆盖规则即可
在Ubuntu上,你可以在/etc/apache2/sites中找到这个
您的文件应如下所示:
<VirtualHost *:80>
ServerName xxx.com
ServerAlias www.xxx.com
ServerAdmin xxx@xxx.com
DocumentRoot /var/www/html/laravel/public/ //<<< add public to your document root
<Directory "/var/www/html/laravel/public"> ## <<< add the override rule if not exists
AllowOverride all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
ServerName xxx.com
ServerAlias www.xxx.com
服务器管理员xxx@xxx.com
DocumentRoot/var/www/html/laravel/public//@rakesharma我在问题“不是文件夹更改解决方案…”中提到的:)