Re: mod_rewrite problems

by Reywob(at)aol.com

 Date:  Mon, 17 Dec 2001 10:01:43 EST
 To:  hwg-servers(at)hwg.org
  todo: View Thread, Original
OK, I finally got it sorted :-)

Thankfully if you give Apache dir//page.html it seemsto ignore the // and 
just treat it as normal, as the following code has this problem - if the 
directory is entered with a trailing slash then this happens.  And I can't 
think of a regex which will select the URL _without_ the trailing slash *and* 
will still work if it isn't present ;-)

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
# Check to see if it's a directory
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ $1/index.html
# Check to see if the file exists
RewriteCond %{REQUEST_FILENAME}  (.*)\.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)\.html$ newindex.php?page=$1 [L]

Peter.

HWG: hwg-servers mailing list archives, maintained by Webmasters @ IWA