Devon
Devon

Reputation: 131

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. Over 300 pages, and 750 blog posts.

I'm looking for a .htaccess 301 redirect for the blog posts, but doing 750 different 301 redirections seems horribly inefficient. I'm already biting the bullet for the 300 pages.

Is there a rewrite rule I can utilize to rewrite the following 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.

Before I invest several hours into the per url basis, I want to see if there is a rewrite condition/rule I can utilize.

Thanks!

Upvotes: 1

Views: 174

Answers (1)

Oliver Maksimovic
Oliver Maksimovic

Reputation: 3262

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".

Upvotes: 1

Related Questions