【问题标题】:.htaccess not working with Laravel.htaccess 不适用于 Laravel
【发布时间】:2015-11-10 00:02:47
【问题描述】:

我正在使用 Laravel 5.1 和一个使用 Apache 的 PuPHPet VM(所以不是 Homestead)。

我的公共目录中有默认的 .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]
</IfModule>

我已经进入了apache2.conf;

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all granted
</FilesMatch>

<Directory />
  Options FollowSymLinks
  AllowOverride All
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

我已经重启了apache2;

sudo service apache2 restart

但我仍然找不到;

http://192.168.56.131/auth/register

但没有;

http://192.168.56.131/public/auth/register

所以我不确定现在该尝试什么。它的一部分必须工作,因为不再需要index.php


* 更新 *

这是有效的;

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

但事实并非如此;

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

它只是不喜欢整个“公共”的东西。

这是我的 apache2.conf 文件的更新部分;

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

真令人沮丧!我不明白我在这里缺少什么。

【问题讨论】:

    标签: php apache .htaccess laravel-5


    【解决方案1】:

    您的 Apache 配置应该放在 vhost 配置文件中,而不是 htaccess。

    PuPHPet 使用 php-fpm,mod_php 支持在几个月前就被放弃了。

    【讨论】:

    • 那为什么 index.php 这么容易被删除呢?
    【解决方案2】:

    试试

    RewriteEngine On
    RewriteRule ^(.*)$ /public/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2020-02-02
      • 2014-03-19
      • 2014-09-30
      • 2017-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多