启用固定链接时,Wordpress会在wamp apache上抛出403禁止错误?

时间:2013-09-19 17:08:43

标签: wordpress apache .htaccess wamp httpd.conf

我已经设置了一个wordpress网站,我启用了永久链接,用seo友好网址打开页面。所以它改变了我的.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

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

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友好网址上运行良好。

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

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

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

2 个答案:

答案 0 :(得分:2)

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

403消息表示它是权限错误。错误可能是由.htaccess文件中的Options +SymLinksIfOwnerMatch等.htaccess文件中缺少的内容或/%year%/%monthnum%/%day%/%postname%//archives/%year%/%monthnum%/%day%/%postname%/的永久链接格式字符串引起的。

我发现有很多人在这个问题上搜索“永久链接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文件,选项将触发错误,我确信您可以放心地忽略。至少它在我的测试服务器上工作。

答案 1 :(得分:0)

使用 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>