37

我在我的电脑上使用 Lamp 服务器。我开始使用 Laravel php 框架。在我的 .htaccess 中,如果我使用Options +FollowSymLinks,我会收到 500 错误。如果我注释掉,我必须index.php在我的所有地址中使用..example:

 /~ytsejam/blog/public/index.php/login

我使用 Arch Linux 。有没有办法解决它?

编辑:我通过使用虚拟主机解决了这个问题。并index.php from application/config/application.php在 laravel 文件夹中删除。

4

3 回答 3

18

您可以尝试在互联网上搜索“.htaccess Options not allowed here”。

我发现的一个建议(使用谷歌)是:

检查以确保您的 httpd.conf 文件具有 AllowOverride All。

在 Mint Linux 上为我工作的 .htaccess 文件(放置在 Laravel /public 文件夹中):

# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html

# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>

# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact

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

希望这对您有所帮助。否则你可以在 Laravel 论坛 (http://forums.laravel.com/) 上提问,那里有一些非常乐于助人的人。

于 2012-08-26T10:20:56.980 回答
8

参数Options FollowSymLinks使您能够在您的 webroot 中拥有一个指向其他文件/目录的符号链接。禁用此功能后,Apache 将拒绝遵循此类符号链接。Options SymLinksIfOwnerMatch可以改用更安全的方法 - 这将允许您仅链接到您拥有的其他文件。

如果您在主 Apache 配置中使用已被禁止的参数中的Options指令,服务器将返回 HTTP 500 错误代码。.htaccess

允许.htaccess的选项由AllowOverride主 Apache 配置文件中的指令定义。要允许符号链接,该指令需要设置为Allor Options

除了允许使用符号链接外,还需要此指令来在上下文中启用mod_rewrite 。.htaccess但为此,也SymLinksIfOwnerMatch可以使用更安全的选项。

于 2015-06-18T09:42:45.707 回答
6

当您访问网站并在 Web 浏览器中浏览到 /system/files/images 文件夹时,服务器如何知道它应该从 /pictures 文件夹中提取 image.png?所谓的符号链接是负责此行为的人。在您的系统中某处,有一个符号链接告诉您的服务器“如果访问者请求 /system/files/images/image.png,则向他显示 /pictures/image.png。”

FollowSymLinks 设置在其中的作用是什么?

FollowSymLinks 与服务器安全有关。在处理 Web 服务器时,您不能只保留未定义的内容。你必须告诉谁可以访问什么。FollowSymLinks 设置告诉你的服务器它是否应该遵循符号链接。换句话说,如果在我们的案例中禁用了 FollowSymLinks,浏览到 /system/files/images/image.png 文件将根据其他设置返回 403(禁止访问)或 404(未找到)错误。

http://www.maxi-pedia.com/FollowSymLinks

于 2014-11-04T10:10:11.227 回答