【问题标题】:htaccess rewrite doesn't work after installing WordPress安装 WordPress 后 htaccess 重写不起作用
【发布时间】:2015-10-20 14:22:28
【问题描述】:

我最近安装了 WordPress。因为我希望它从根目录运行并且喜欢一些漂亮的永久链接,所以我在我服务器的 httpdocs 上的 htaccess 文件中添加了一个新部分。

从那时起,其他域的重定向不再起作用。

这是当前代码:

Options +FollowSymLinks
RewriteEngine On

#Redirect to other DOMAINS
#----------------
RewriteCond %{HTTP_HOST} (www\.)?example1.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/e1/.*$
RewriteRule ^(.*)$ /e1/$1

RewriteCond %{HTTP_HOST} (www\.)?example2.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/SR/.*$
RewriteRule ^(.*)$ /SR/$1

#ALTERNATE DOMAINS
# ---------------
RewriteCond %{HTTP_HOST} ^www.gw.nl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^gw.nl$ [NC]
RewriteRule (.*) http://www.gw.info/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www.cb.nl$ [NC,OR]
RewriteCond %{HTTP_HOST} ^cb.nl$ [NC]
RewriteRule (.*) http://www.gw.info/$1 [R=301,L]

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

# END WordPress

WordPress 网站可以正常工作。备用域也可以。但是,其他两个网站完全停止运行,现在显示主要的 wordpress 网站。

如果我将RewriteRule . /wordpress/index.php [L] 更改为RewriteRule . /index.php [L],它将返回内部服务器错误。

有人知道这是什么错误吗?

【问题讨论】:

  • 前两条规则中可能缺少标志 ([R=301,L]),请尝试使用绝对 URL,即“example1.com...”
  • 感谢费利佩!添加标志有帮助!

标签: wordpress apache .htaccess mod-rewrite


【解决方案1】:

添加标志

[R=301,L]

前两条规则有效!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多