【问题标题】:how to redirect 301 in wordpress如何在wordpress中重定向301
【发布时间】:2014-08-26 08:38:35
【问题描述】:

如何在 wordpress 中使用 .htaccess 文件进行 301 重定向。

www.mysite.com/about.html/page1
www.mysite.com/about.html/page2
www.mysite.com/about.html/page3
www.mysite.com/about.html/page(anypage)

重定向到

 www.mysite.com/

我该如何做这样的重定向。

以下重定向对我不起作用

Redirect 301 about.html/ /

结果是www.mysite.com//page1 这是错误的。我想将整个 url 重定向到我的主页。

【问题讨论】:

  • 我认为你需要设置重写库,而不是像Redirect 301 ^about.hrml.*$ /

标签: php wordpress .htaccess


【解决方案1】:

试试这个:

RewriteRule ^about\.hrml(.*)$ http://www.example.com/ [R=301,L]

模式匹配以about.hrml 开头的任何内容(注意hrml 之前的. 被转义,因为它是正则表达式,. 表示任何非换行符)。使用您自己的 URL 重定向到您的网站(替换 http://www.example.com)。 R=301 告诉服务器使用 301 代码,L 表示这应该是最后一条规则。

【讨论】:

  • 嗨,@jonathon 你能帮我解决这个问题吗?抱歉,我正在输入 html as hrml 我在我的 htaccess 中添加了以下代码。你能检查我的代码吗
  • # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteRule ^about-us\.html$ http://www.example.com/ [R=301,L] </IfModule> # END WordPress
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-10-06
  • 2013-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-19
  • 2012-04-20
相关资源
最近更新 更多