简体   繁体   English

301 重定向 htaccess 配置

[英]301 redirects htaccess configuration

I'm working on a website Drupal to Wordpress conversion for a client, and the site has a LOT of content.我正在为客户处理一个从 Drupal 到 Wordpress 转换的网站,该网站有很多内容。 Over 300 pages, and 750 blog posts.超过 300 页和 750 篇博文。

I'm looking for a .htaccess 301 redirect for the blog posts, but doing 750 different 301 redirections seems horribly inefficient.我正在为博客文章寻找 .htaccess 301 重定向,但执行 750 个不同的 301 重定向似乎效率极低。 I'm already biting the bullet for the 300 pages.我已经为 300 页咬紧牙关了。

Is there a rewrite rule I can utilize to rewrite the following url?是否有重写规则可以用来重写以下 url?

Redirect 301 http://website.org/blog/YYYY/MM/DD/Post-title 

to http://website.org/blog/Post-title/

The dates go from 2016 to 2008.日期从 2016 年到 2008 年。

Before I invest several hours into the per url basis, I want to see if there is a rewrite condition/rule I can utilize.在我在每个 url 基础上投入几个小时之前,我想看看是否有我可以利用的重写条件/规则。

Thanks!谢谢!

This should do it:这应该这样做:

RewriteRule ^blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)?$ /blog/$4 [R=301,L]

This matches "4 digits/2 digits/2 digits/whatever" and rewrites such requests to "/blog/whatever".这匹配“4 位数字/2 位数字/2 位数字/任何”并将此类请求重写为“/blog/whatever”。

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

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