Apache 打开重写引擎会产生403错误--如何打开FollowSymLinks?

Apache 打开重写引擎会产生403错误--如何打开FollowSymLinks?,apache,mod-rewrite,apache2,symlink,httpd.conf,Apache,Mod Rewrite,Apache2,Symlink,Httpd.conf,我正在OSX上使用内置的Apache2。我将文档根目录移动到桌面上的一个文件夹中,并确保\u www和每个人都有读取权限。它工作得很好,PHP工作得很好,在我添加一个.htaccess之前,一切都工作得很好,只有这一行: RewriteEngine on 一旦我这样做,目录中包含文件的所有内容都是403禁止的: Forbidden You don't have permission to access /dir/file.txt on this server. Apache日志显示此错误:

我正在OSX上使用内置的Apache2。我将文档根目录移动到桌面上的一个文件夹中,并确保
\u www
每个人都有读取权限。它工作得很好,PHP工作得很好,在我添加一个
.htaccess
之前,一切都工作得很好,只有这一行:

RewriteEngine on
一旦我这样做,目录中包含文件的所有内容都是403禁止的:

Forbidden
You don't have permission to access /dir/file.txt on this server. 
Apache日志显示此错误:

[错误][client 127.0.0.1]选项FollowSymLinkssymlinksFownerMatch处于关闭状态,这意味着重写规则指令被禁止:/Users/uname/Desktop/localhost/dir/filename.txt

我已经查看了
httpd.conf
,并确保启用了
FollowSymLinks
但无效:

DocumentRoot "/Users/uname/Desktop/localhost"
<Directory />
    Options FollowSymLinks
    Options SymLinksIfOwnerMatch 
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<Directory "/Users/uname/Desktop/localhost">
    Options FollowSymLinks
    Options SymLinksIfOwnerMatch 
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
DocumentRoot”/Users/uname/Desktop/localhost
选项如下符号链接
选项SYMBOLINKSIFOWNERMATCH
允许超越所有
命令允许,拒绝
通融
选项如下符号链接
选项SYMBOLINKSIFOWNERMATCH
选项索引多视图
允许超越所有
命令允许,拒绝
通融
如果我在
.htaccess
文件中注释掉
RewriteEngine on
,那么很明显,除了重写规则之外,一切都正常。在OSX 10.8.5上,
httpd.conf
位于
/etc/apache2
中,该文件夹也有
users
文件夹,其中包含单独的文件供使用,例如
uname.conf
,但我在这里添加了与其他文件夹相同的符号链接。我注意到还有一个文件夹
extra
,其中包含
httpd userdir.conf
等文件,但它们似乎没有禁用任何功能


还有什么地方可以打开(或关闭)FollowSymLinks?

您必须将选项放在一行,或者在选项前面添加一个
+
符号,以便Apache了解您想要合并它们。目前仅应用最后一个Options指令(“Options INDEX MULTIVIES”),因为它覆盖了所有先前的选项

尝试此操作(将覆盖“/”选项):


选项索引多视图跟随符号链接符号链接所有者匹配
允许超越所有
命令允许,拒绝
通融

我在获得403时遇到了问题,我的解决方案是更改重写规则。我的全部指示如下:

<Directory "/var/www/">

<LimitExcept GET POST HEAD>
  Order Allow,Deny
  Deny from all
  Satisfy all
</LimitExcept>

Require all granted
AllowOverride None

# Disable includes and cgi
Options -Includes
Options -ExecCGI

<IfModule mod_rewrite.c> 

RewriteEngine On

# Redirdect to HTTPS
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^(.*)$ - [F,L]

# Put your installation directory here:
RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# remove index.php
RewriteRule ^(.*)$ /index.php/$1 [L]

# If your host requires forcing query strings.
# Notice the question at the end of index.php 
# on the last rule
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php?/$1 [L]

</IfModule> 

</Directory>
ServerName www.example.com
ServerAlias www.example.com

命令允许,拒绝
全盘否定
满足所有
要求所有授权
不允许超限
#禁用包含和cgi
选项-包括
选项-执行CGI
重新启动发动机
#重定向到HTTPS
RewriteCond%{HTTP_HOST}^example.com
重写规则(.*)http://www.example.com/$1[R=301,L]
RewriteCond%{HTTP_USER_AGENT}^$
重写规则^(.*)$-[F,L]
#将安装目录放在此处:
重写基/
#不要为存在的文件或目录启用重写
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#删除index.php
重写规则^(.*)$/index.php/$1[L]
#如果您的主机需要强制查询字符串。
#注意index.php末尾的问题
#最后一条规则
#重写cond%{REQUEST_FILENAME}-F
#重写cond%{REQUEST_FILENAME}-D
#重写规则^(.*)$/index.php?/$1[L]
服务器名www.example.com
ServerAlias www.example.com

FollowSymLinks
symlinksFownerMatch
不应该在一起,因为Apache如何尊重它们,因为它们的行为不同。@上帝是爱的,虽然将它们一起使用可能不是一个好形式,但这肯定不是一个错误。Apache只会使用更具体的选项,而忽略另一个选项。OP最初的问题是他们如何使用选项。这就是我选择关注的。请更明智地使用你的反对票。这不是建设性地使用否决票。
<Directory "/var/www/">

<LimitExcept GET POST HEAD>
  Order Allow,Deny
  Deny from all
  Satisfy all
</LimitExcept>

Require all granted
AllowOverride None

# Disable includes and cgi
Options -Includes
Options -ExecCGI

<IfModule mod_rewrite.c> 

RewriteEngine On

# Redirdect to HTTPS
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^(.*)$ - [F,L]

# Put your installation directory here:
RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# remove index.php
RewriteRule ^(.*)$ /index.php/$1 [L]

# If your host requires forcing query strings.
# Notice the question at the end of index.php 
# on the last rule
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php?/$1 [L]

</IfModule> 

</Directory>
ServerName www.example.com
ServerAlias www.example.com