htaccess: how to prevent infinite subdirectories?

Posted by Vincent Isles on Stack Overflow See other posts from Stack Overflow or by Vincent Isles
Published on 2010-06-05T16:38:01Z Indexed on 2010/06/05 16:42 UTC
Read the original article Hit count: 219

Filed under:

My .htaccess at the root directory contains this:

Options -MultiViews +FollowSymlinks -Indexes
ErrorDocument 404 /404.htm
RewriteEngine On
RewriteBase /

followed by a bunch of RewriteRules. The .htaccess at the /forum subdirectory contains this:

RewriteEngine On
RewriteBase /forum
RewriteRule ^index.html$ index.php [L,NE]
RewriteRule ^(.*)-t-([0-9]+).html(.*)$ showthread.php?tid=$2$3 [QSA,L]
RewriteRule ^(.*)-t-([0-9]+)-([0-9]+).html$ showthread.php?tid=$2&page=$3 [QSA,L]

followed by other rules mapping SEO-friendly URLs to the true URLs.

mydomain.com/forum/a-thread-t-1.html returns the page showthread.php?tid=1 but so does mydomain.com/forum/forum/a-thread-t-1.html, mydomain.com/forum/forum/forum/a-thread-t-1.html and so on. I don't want this behavior - I want pages accessed as /forum/forum/* to return a 404.

Any hint on where I had been wrong?

© Stack Overflow or respective owner

Related posts about .htaccess