简体   繁体   English

WordPress .htaccess RewriteRule无效

[英]WordPress .htaccess RewriteRule not working

Relaunched a website and a lot of old pages need to be redirected to new ones. 重新启动一个网站,需要将许多旧页面重定向到新的页面。

I thought this would be simple with htaccess but wordpress has other ideas. 我认为这对于htaccess来说很简单,但是wordpress还有其他想法。 Htaccess's 'Redirect 301' doesn't appear to be supported with all the stuff wordpress does. Htaccess的'Redirect 301'似乎不受wordpress所有功能的支持。 A lot of forums and posts suggest 'RewriteRule'. 很多论坛和帖子都提出了“RewriteRule”。

Here is the htaccess code I am working with in the root directory. 这是我在根目录中使用的htaccess代码。 My code is the two lines starting with 'RewriteBase /'. 我的代码是以'RewriteBase /'开头的两行。 I hoped that by going to http://www.example.com.au/skps/contact.html it would redirect me to http://www.example.com.au/about/ . 我希望通过访问http://www.example.com.au/skps/contact.html,它会将我重定向到http://www.example.com.au/about/ This just does not work. 这不行。

DirectoryIndex index.html index.htm index.php

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
#
RewriteBase /
RewriteRule ^skps/contact.html$‎ http://www.example.com.au/about/ [R=301,L]
#
RewriteBase /digiseen/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /digiseen/index.php [L]
</IfModule>

# END WordPress

While this doesn't directly answer your question, I've had better luck using the Redirection plugin for this sort of thing. 虽然这并没有直接回答你的问题,但我有更好的运气使用Redirection插件来做这类事情。

It's pretty easy to use, and when I'm doing a redesign or changing site structure I use this plugin for a few months (until the search engines have re-indexed the site). 它很容易使用,当我重新设计或更改网站结构时,我使用这个插件几个月(直到搜索引擎重新索引网站)。 Of course, you can leave it on indefinitely if you wish. 当然,如果您愿意,可以无限期地将其保留。

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

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