【问题标题】:laravel htaccess not working correctly?laravel htaccess 无法正常工作?
【发布时间】:2013-06-07 10:35:23
【问题描述】:

我对 laravel 框架有一个奇怪的地方。
apache 无法读取位于 laravel 框架内公用文件夹中的 .htaccess。
这是虚拟主机的配置文件。

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/zafaty/public
    ServerName  zafaty.dev
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/zafaty/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AddHandler cgi-script .cgi .pl
        AllowOverride All
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这是 .htaccess 文件。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

我也试过这个

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

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

但它也没有用。
我仍然可以访问这样的路由 http://zafaty.dev/index.php/example 但是当尝试正常访问时 http://zafaty.dev/example 它给出了 404 错误
顺便说一句,我正在使用 linux mint nadia。

【问题讨论】:

    标签: apache .htaccess mod-rewrite laravel


    【解决方案1】:

    只是在黑暗中拍摄,因为我遇到了同样的问题,这解决了它....

    确保您的 httpd.conf 包含以下行:

    AccessFileName .htaccess
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多