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

Exclude subdirectories from redirect
limit scope of htaccess redirects

10+ Year Member

Msg#: 374 posted 6:08 pm on Sep 5, 2003 (gmt 0)

I'm using htaccess to redirect users to extensionless files on my site:
RedirectMatch permanent /(.*)\.html$ [mysite.com...]

However, I would like to limit this redirection to files that are in my root directory and exclude subdirectories from the redirect rule.

It would be fine to exclude all subdirectories or just exclude specific ones; I don't care.

Is there a way to do this?



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

Msg#: 374 posted 10:38 pm on Sep 6, 2003 (gmt 0)


Welcome to WebmasterWorld [webmasterworld.com]!

Redirect any URL which contains a slash followed by any number of characters which are not a slash, followed by ".html" to a resource of the same name in root, but without a file extension:

RedirectMatch permanent ^/([^/]*)\.html$ http://mysite.com/$1

Ref: [etext.lib.virginia.edu...]



10+ Year Member

Msg#: 374 posted 1:15 pm on Sep 8, 2003 (gmt 0)

Thanks! Works great! Now why didn't I think of that?

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