简体   繁体   English

启用永久链接后,Wordpress 在 wamp apache 上抛出 403 禁止错误?

[英]Wordpress throws 403 forbidden error on wamp apache when enabled permalink?

I have setup a wordpress website on which I enabled permalink to open the pages with seo friendly urls.我已经设置了一个 wordpress 网站,在该网站上我启用了永久链接以打开带有 seo 友好网址的页面。 So it changed my .htaccess as below所以它改变了我的 .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

But now when I try to access the website on localhost, it throws error as但是现在当我尝试访问本地主机上的网站时,它会抛出错误

Forbidden

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

I tried to look into the apache error logs and found this我试图查看 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/

So to fix this what I did is, I added below line before # BEGIN Wordpress所以为了解决这个问题,我所做的是,我在#BEGIN Wordpress之前添加了以下行

Options FollowSymLinks

And that got fixed and site worked fine with seo friendly urls.这得到了修复,并且站点可以通过 seo 友好的 url 正常工作。

But the main issue is, it seems that there is some misconfiguration or some kind of security set on apache under wamp on my system.但主要问题是,我的系统上 wamp 下的 apache 似乎存在一些错误配置或某种安全设置。 As every time if I create any site with the htaccess file having this code, it throws same 403 Forbidden error.每次如果我使用具有此代码的 htaccess 文件创建任何站点,它都会抛出相同的403 Forbidden错误。

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

Here is the link to my httpd.conf file on apache, just in case anybody need to check it.这是我在 apache 上的 httpd.conf 文件的链接,以防万一有人需要检查它。 http://pastebin.com/LFxNTsnR http://pastebin.com/LFxNTsnR

I did a search, and I found a few issues that could cause this problem.我进行了搜索,发现了一些可能导致此问题的问题。

A 403 message means it's a permission error. 403消息意味着这是一个权限错误。 The error can be caused because of something missing in the .htaccess file like Options +SymLinksIfOwnerMatch at the top of the .htaccess file, or the permalink format string from /%year%/%monthnum%/%day%/%postname%/ to /archives/%year%/%monthnum%/%day%/%postname%/ .该错误可能是由于 .htaccess 文件中缺少某些内容引起的,例如 .htaccess 文件顶部的Options +SymLinksIfOwnerMatch ,或来自/%year%/%monthnum%/%day%/%postname%/的永久链接格式字符串到/archives/%year%/%monthnum%/%day%/%postname%/

I found a bunch of people with this issue doing a search on Google for 'permalink 403 error'.我发现很多有这个问题的人在 Google 上搜索“永久链接 403 错误”。 http://wordpress.org/support/topic/permalink-403-error http://wordpress.org/support/topic/permalink-403-error

Try changing the httpd.conf file as such: In your httpd.conf (or one of the included .conf files) is a reference to your website directory. 尝试像这样更改 httpd.conf 文件:在您的 httpd.conf(或包含的 .conf 文件之一)中是对您网站目录的引用。 It will look something like this:它看起来像这样:

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

Add the mod_rewrite directive in between the tags to enable the permalink feature in your site:在标签之间添加 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>

For more permalink control without .htaccess support, install the redirection plugin.要获得更多不支持 .htaccess 的永久链接控制,请安装重定向插件。 Without a valid .htaccess file, the options will trigger an error that I'm sure you can safely ignore.如果没有有效的 .htaccess 文件,这些选项将触发一个错误,我相信您可以放心地忽略该错误。 At least it worked on my test server.至少它在我的测试服务器上工作。

using bitnami wamp, in my virtualhost I had:使用 bitnami wamp,在我的虚拟主机中,我有:

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

I changed it to:我把它改成:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM