1

我已经设置了一个 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

4

2 回答 2

2

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

一条403消息意味着它是一个权限错误。该错误可能是由于 .htaccess 文件中缺少某些内容(例如 .htaccess 文件Options +SymLinksIfOwnerMatch顶部)或从 to 的永久链接格式字符串而/%year%/%monthnum%/%day%/%postname%/导致的/archives/%year%/%monthnum%/%day%/%postname%/

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

尝试更改 httpd.conf 文件: 在您的 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 文件,这些选项将触发一个错误,我相信您可以放心地忽略该错误。至少它在我的测试服务器上工作。

于 2013-09-19T17:37:24.497 回答
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>
于 2021-03-31T18:29:02.517 回答