.htaccess用于安装在子文件夹中的Laravel应用

时间:2019-03-11 09:29:21

标签: php laravel .htaccess

我有一个域,例如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的禁止返回

0 个答案:

没有答案