Welcome to WebmasterWorld Guest from 174.129.135.89

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Help With Using Redirectmatch

Redirectmatch

   
1:02 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



Greetings,
Looking for a bit of help on if redirectmatch will solve my problem.

I am trying to do a permanent redirect from the following:

http://example.com/old-sub-cat/article-10.shtml --- redirect to --->

http://example.com/cat/new-sub-cat/article-10.shtml

Can I use reditectmatch to accomplish this? I am try to avoid adding individual lines to .htaccess because I have thousands to do.

Here is what I was thinking:

RedirectMatch /old-sub-cat/article-*.shtml http://example.com/cat/new-sub-cat/article-$.sthml

Am I close?

Appreciate all help.

Thanks.

2:51 pm on Jun 18, 2007 (gmt 0)

5+ Year Member



If you are moving the whole directory then a simple redirect will do the work.

RedirectPermanent /old-sub-cat/ http://example.com/cat/new-sub-cat/

Well you were quite close in your RedirectMatch

RedirectMatch /old-sub-cat/article-(*).shtml http://example.com/cat/new-sub-cat/article-$.sthml

Milan

2:53 pm on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Your regular-expressions pattern is not quite right, the redirect type is not specified, and the back-reference syntax is incorrect. Try:

RedirectMatch 301 ^/old-sub-cat/article-([^.]+)\.shtml$ http://example.com/cat/new-sub-cat/article-$1.shtml

I'm also assuming that the "sthml" in the substitution URL was a typo.

For more information, see the Apache mod_alias documentation [httpd.apache.org] and the documents cited in our forum charter [webmasterworld.com], particularly the regular-expressions tutorial cited there.

Jim

[edited by: jdMorgan at 2:54 pm (utc) on June 18, 2007]

12:44 am on Jun 19, 2007 (gmt 0)

10+ Year Member



Thanks for the help! I will give the above a try. I am hopeful this will solve my problem.