Tomasz
Tomasz

Reputation: 1368

Redirect multiple URLs (number included in URL) to the same new one

I have 3 URLs like:

http://example.com/archives/2001_2005/
http://example.com/archives/2006/
http://example.com/archives/2007/

How to use .htaccess to 301-redirect all of them to:

http://example.com/archives/2001-2007/

I tried this below but it doesn't work (I prefer with as simple one line as posssible):

RewriteRule ^archives/(2001_2005|2006|2007) http://example.com/archives/2001-2007/ [R=301,L]

Upvotes: 2

Views: 790

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

You can use RedirectMatch :

RedirectMatch 301 ^/archives/(2001_2005|2006|2007) http://example.com/archives/2001-2007

Clear your browser cache before testing this.

Upvotes: 1

Related Questions