user2430227
user2430227

Reputation: 303

How do I use htaccess to redirect multiple URLs of the same format to a new format?

I am trying to redirect multiple URLs of the same format to a different format of URLs with one statement.

Original Format: http://example.com/blog/YYYY/MM/example-title/

where YYYY is a number from 2013 - 2017 and MM is a single OR double digit number between 1-12 OR 01-12 and example title can be any length, any letters, with dashes for spaces.

New Format: http://example.com/blog/example-title.php

Please help, thank you!

Upvotes: 1

Views: 35

Answers (1)

anubhava
anubhava

Reputation: 785376

Have this rule inside your /blog/.htaccess (create it if it doesn't exist):

RewriteEngine On
RewriteBase /blog/

RewriteRule ^\d+/\d+/([^/]+)/?$ $1.php [L,NE,R=301]

# other rules go here

Upvotes: 2

Related Questions