Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Help With Using Redirectmatch


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

Junior Member

10+ Year Member

joined:Feb 8, 2005
votes: 0

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 --->


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.


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

Full Member

10+ Year Member

joined:Jan 4, 2006
votes: 0

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


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

Senior Member

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

joined:Mar 31, 2002
votes: 0

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.


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

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

Junior Member

10+ Year Member

joined:Feb 8, 2005
votes: 0

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