简体   繁体   English

.htaccess永久链接重定向

[英].htaccess Permalink redirect

I'd like to redirect my Wordpress posts from /%title/ to %year/%month/%title/. 我想将我的Wordpress帖子从/%title /重定向到%year /%month /%title /。

Since WP automatically redirects the pages when you do a new permalink structure, I'd like to have the redirect in my .htaccess file anyway so that Google is aware of the change. 由于WP在执行新的永久链接结构时会自动重定向页面,因此无论如何我都希望在.htaccess文件中进行重定向,以便Google知道更改。

This is what I have in my .htaccess file, so I'd just liket to confirm this is the correct structure: 这是我的.htaccess文件中的内容,因此我只想确认这是正确的结构:

RedirectMatch 301 http://url-example.com/$3 ^/([0-9]{4})/([0-9]{2})/(.*)$

Let me know, thanks. 让我知道,谢谢。

Due to the dynamic nature of the WordPress URLs, I do not believe you will have much luck doing this in a single rule. 由于WordPress URL的动态性质,我相信您不会在一条规则中就这么走运。

You could explicitly list these in .htaccess . 您可以在.htaccess明确列出这些内容。 However, it's likely WordPress is handling these redirects correctly for Google (ie 301). 但是,很可能WordPress正在为Google(即301)正确处理这些重定向。

Use Firebug or HTTP Live Headers to verify. 使用Firebug或HTTP Live标头进行验证。

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

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