Welcome to WebmasterWorld Guest from 54.196.231.129

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Exclude subdirectories from redirect

limit scope of htaccess redirects

     
6:08 pm on Sep 5, 2003 (gmt 0)

New User

10+ Year Member

joined:Sept 5, 2003
posts:19
votes: 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?
Thanks!

10:38 pm on Sept 6, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


Dan121,

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

Jim

1:15 pm on Sept 8, 2003 (gmt 0)

New User

10+ Year Member

joined:Sept 5, 2003
posts:19
votes: 0


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