[thelist] Apache Rewrite

Mark Gillingham markgill at uwalumni.com
Tue Feb 26 12:51:01 CST 2002


I have a file .htaccess at the top of my site with a series of rules
because our site was restructured and I wanted old bookmarks to work.
Mostly, the rules work as expected, but I am having great difficulty
understanding how to write a rule for the following condition.

/section1/* has been changed to /programs/section1/*

and the previous extension (.html) has been changed to ".shtml."

My current rule works for a call like this:

/section1/subsection/page.shtml -->
/programs/section1/subsection/page.shtml

but does not handle the more frequent case in which the older extension
is used:

/section1/subsection/page.html --> ERROR

My rules follow. Notice that I always send users to the top of the
subsection because I can't get the .html to be .shtml.

# Redirect /section1/ to /programs/section1/
RewriteRule ^ section1/$           programs/section1/index.shtml  [L]
# ELSE redirect to a safe place at the begining of the Junior section
RewriteRule ^ section1/(.*)           programs/section1/  [L]




More information about the thelist mailing list