【发布时间】:2019-03-11 19:57:08
【问题描述】:
我有一个域名,例如www.example.com
主站点位于 FTP 空间上,显示为 /example.com
我在/example.com/laravel_app 下安装了(复制/粘贴,叹息...:()我的 Laravel 应用程序。
如果我使用完整的 url http://www.example.com/laravel_app/public/index.php 访问,我可以打开 laravel 应用程序,它可以正常工作。
问题是,很明显,我只想使用路径http://www.example.com/laravel_app 来访问它。
在laravel_app的根目录下,我尝试粘贴这个.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
在/example.com/laravel_app/public 中,我正在使用这个`.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /laravel_app/
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
所以我的问题与应用程序公用文件夹的.htaccess 无关,而与应用程序根文件夹的.htaccess 无关。
如何才能成功发球
http://www.example.com/laravel_app/public/index.php
访问
http://www.example.com/laravel_app
?
实际上我让 Laravel 返回了 404
我尝试了这个变体(看到我的一些问题与这个非常相似)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php/$1 [L]
</IfModule>
但是有了这个我得到了 apache 返回一个禁止
【问题讨论】: