ok, so i’m relatively new to .htaccess and redirects but I’ve been searching high and low for this solution and it’s driving me crazy.
Right now I’m redirecting my old blogger blog to wordpress.
So, I have this code in place:
RedirectMatch 301 /2014/01(.*) /journal/trip1/$1
This redirects:
www.website.com/2014/01/BlogTitle
to:
www.website.com/journal/trip1/BlogTitle
This all works great EXCEPT it’s also redirecting my images in the “wp-content/uploads/2014/01” folder because it matches the “2014/01” in the redirect
The image should be here:
http://www.website.com/wp-content/uploads/2014/01/SomeImage.jpg
Instead it redirects to here:
http://www.website.com/journal/trip1/SomeImage.jpg
Like I said, I’ve searched high and low for solutions and I’m sure it’s something ridiculously easy.
Any help greatly appreciated!
Thanks
Todd
As mentioned in the comment by @Hobo, you are not checking from the beginning of the URI. This means that anything before
/2014/01
will also be matched. As such, you’ll need to add^
before the/2014
. It should now look like this:As a rule of thumb, it’s also better to end the expression with
$
.Alternatively, you can use
mod_rewrite
to do the redirect. Using the condition and rule below, you can do the redirect whilst ensuring the requested URI does not map to an existing file.Also, per @Hobo’s comment, you should always do a temporary redirect instead of a permanent one when testing. Once you’re happy with either of the above (i.e. they’re working as expected) change both
302
s to301
s.What if you apply the solution said by @MikeRockett and @Hobo, but, instead denying any found file
deny only the images on your URI
Not sure if it’s the real solution. I’d say that in a comment, but I’ve got not enough points yet