AmandaI
AmandaI

Reputation: 25

Redirect if a URL contains this string

I don't know much about .htaccess, but I'm trying to help a friend who recently moved his blog to Wordpress.

We need to redirect the OLD archive pages like this:

to NEW archive pages like this: I've tried everything I can find using htaccess redirect and rewrite, but again, I don't really know what I'm doing with htaccess!

Thanks so much for your help, Amanda

OK tried this:

Turn mod_rewrite on

RewriteEngine On RewriteRule ^([0-9]{4})([0-9]{2})([0-9]{2})_archive.html$ /$1/$2/$3 [L,R=301]

in .htaccess in the very top level folder of my site. Still, when I go to http://www.bikermetric.com/2010_04_01_archive.html, it doesn't redirect.

Just tried this too: RedirectMatch 301 ^/([0-9]{4})([0-9]{2})([0-9]{2})_archive.html$ /$1/$2/$3

Still nothing.

Upvotes: 1

Views: 760

Answers (1)

Jon Lin
Jon Lin

Reputation: 143966

You can use mod_alias or mod_rewrite here. You'll want to stick with using mod_rewrite if you already have rewrite rules (stuff that look like RewriteEngine or RewriteRule):

mod_alias:

RedirectMatch 301 ^/([0-9]{4})_([0-9]{2})_([0-9]{2})_archive.html$ /$1/$2/$3

mod_rewrite:

RewriteEngine On
RewriteRule ^([0-9]{4})_([0-9]{2})_([0-9]{2})_archive.html$ /$1/$2/$3 [L,R=301]

You'd want to add it to the htaccess file in your document root.

Upvotes: 2

Related Questions