【问题标题】:Wordpress throws 403 forbidden error on wamp apache when enabled permalink?启用永久链接后,Wordpress 在 wamp apache 上抛出 403 禁止错误?
【发布时间】:2013-09-24 21:47:38
【问题描述】:

我已经设置了一个 wordpress 网站,在该网站上我启用了永久链接以打开带有 seo 友好 url 的页面。所以它改变了我的 .htaccess 如下

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /brt_blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my_blog/index.php [L]
</IfModule>
# END WordPress

但是现在当我尝试访问本地主机上的网站时,它会抛出错误

Forbidden

You don't have permission to access /my_blog/ on this server.

我试图查看 apache 错误日志并找到了这个

[Thu Sep 19 22:33:29 2013] [error] [client 127.0.0.1] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: D:/www/brt_blog/, referer: http://localhost/

为了解决这个问题,我在 # BEGIN Wordpress

之前添加了以下行
Options FollowSymLinks

这个问题得到了修复,网站在 seo 友好的 url 上运行良好。

但主要问题是,我的系统上的 wamp 下的 apache 上似乎存在一些错误配置或某种安全设置。每次如果我使用具有此代码的 htaccess 文件创建任何站点,它都会引发相同的 403 Forbidden 错误。

<IfModule mod_rewrite.c>
RewriteEngine On
.... my rewrite rules here...
</IfModule>

这是我在 apache 上的 httpd.conf 文件的链接,以防万一有人需要检查它。 http://pastebin.com/LFxNTsnR

【问题讨论】:

    标签: wordpress apache .htaccess wamp httpd.conf


    【解决方案1】:

    我进行了搜索,发现了一些可能导致此问题的问题。

    403 消息表示权限错误。该错误可能是由于 .htaccess 文件中缺少某些内容(如 .htaccess 文件顶部的Options +SymLinksIfOwnerMatch)或从/%year%/%monthnum%/%day%/%postname%//archives/%year%/%monthnum%/%day%/%postname%/ 的永久链接格式字符串。

    我发现一群有此问题的人在 Google 上搜索“永久链接 403 错误”。 http://wordpress.org/support/topic/permalink-403-error

    Try changing the httpd.conf file as such: 在您的 httpd.conf(或包含的 .conf 文件之一)中是对您网站目录的引用。它看起来像这样:

    <Directory "/var/www/path/to/your/web/dir">
      Options ...
      ...
      etc.
    </Directory>
    

    在标签之间添加 mod_rewrite 指令以在您的网站中启用永久链接功能:

    <Directory "/var/www/path/to/your/web/dir">
      ...
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]
      </IfModule>
    </Directory>
    

    要获得更多不支持 .htaccess 的永久链接控制,请安装重定向插件。如果没有有效的 .htaccess 文件,这些选项将触发一个错误,我相信您可以放心地忽略该错误。至少它在我的测试服务器上工作。

    【讨论】:

    • 是的,这就是我所说的,我通过在 htaccess 文件中添加 Options FollowSymLinks 行来修复它,但是正如您所看到的,所有其他网站都不应该是这种情况。我的意思是 apache 中必须有全局设置来设置 FollowSymLinks 或其他东西
    【解决方案2】:

    在我的虚拟主机中使用 bitnami wamp:

    <Directory "path-to-site">
        Options Indexes FollowSymLinks
        AllowOverride All
        Options None # observe this line 
        Require all granted
    </Directory>
    

    我改成:

    <Directory "path-to-site">
        Options Indexes FollowSymLinks
        AllowOverride All
        Options all # set to all and htaccess is happy
        Require all granted
    </Directory>
    

    【讨论】:

      猜你喜欢
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-14
      • 2013-08-29
      • 2019-06-19
      • 1970-01-01
      相关资源
      最近更新 更多