Ok, I'll get straight to the problem: My htaccess is bypassed if there is a php file with the same name as a part of my rewritten virtual URL. Here's an example: Let's assume my root directory structure is this: [..] .htaccess b.php index.php My .htaccess file looks like this: Options -Indexes Options +FollowSymlinks DirectoryIndex index.php RewriteEngine on RewriteBase / [B]RewriteRule ^a/(.*)\.html$ index.php?page=something1&var=$1 [L] RewriteRule ^b/(.*)\.html$ index.php?page=something2&var=$1 [L][/B] Code (markup): So basically, users can use site/a/var.html and site/b/var.html instead of the ugly index.php?page=.... Ok, so my problem comes after switching hosting companies. On my previous hosting company, everything worked fine. Here, however, the second RewriteRule doesn't work any more (giving a 404 instead). After a lot of headaches trying to figure why the first line works, but the second doesn't, I realized that the only difference was that there was a file (b.php) with the same name of one of the virtual directories created with the htaccess file. So my obvious question is why is this happening, and is there anyway I can disable it? P.S.: Only solutions that work are either to actually create an empty b/ directory in the root dir, or rename the b.php file (like _b.php or whatever). P.S.2: Some of the differences the second hosting company (where this is happening) has over the first one: 1. "Files processed by Apache are affected by .htaccess settings, whereas files passed to and processed by Tomcat bypass these settings. Below is a list of file extensions for which Apache is responsible. Files not appearing in this list are processed by Tomcat." (and then there's a long list of extensions, but they do include php/html/jpg etc.) 2. "...we run PHP as a CGI and not as a module...". 3. " Operating System Red Hat Linux Kernel Version 2.4.21-4.0.1 elsmp Web Server Apache 1.3 Web Programming Languages PHP 4.3.11 Tomcat (Java) 5.0.27 CGI / Perl 5.8 Python 2.2 Frontpage 5.0.2.5012 Databases MySQL 4.0.24 "
Try this: Options -Indexes Options +FollowSymlinks DirectoryIndex index.php RewriteEngine on RewriteBase / RewriteRule ^a/(.*)\.html$ index.php?page=something1&var=$1 RewriteRule ^b/(.*)\.html$ index.php?page=something2&var=$1 [L] Code (markup): Take out that Last flag [L] from the first RewriteRule, it means stop rewriting.