homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Help With Using Redirectmatch

10+ Year Member

Msg#: 3371007 posted 1:02 pm on Jun 18, 2007 (gmt 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.




5+ Year Member

Msg#: 3371007 posted 2:51 pm on Jun 18, 2007 (gmt 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



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

Msg#: 3371007 posted 2:53 pm on Jun 18, 2007 (gmt 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]


10+ Year Member

Msg#: 3371007 posted 12:44 am on Jun 19, 2007 (gmt 0)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved