Forum Moderators: phranque
Here is folder structure of my site (it's an example):
folder1/
-.htaccess
folder2/
-somescript.php
.htaccess
index.php
in root .htaccess I have next directives:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^.*$ index.php [L,QSA]
folder1/.htaccess contains
Deny From All
so the RewriteRule should pass all queries to index.php.
But when I try to use somthing like this http://example.com/folder1/, apache shows me 403 Forbidden message. However, when I use http://example.com/folder2/, my rule works ok.
But if i try http://example.com/folder2/somescript.php apache executes this somescript.php. I didn't expect this.
So, can somebody help me with this problem? I want to make all queries go through single index.php
[edited by: coopster at 9:07 pm (utc) on Feb. 19, 2009]
[edit reason] please use example.com, thanks! [/edit]
RewriteCond $1 !index\.php
RewriteRule ^(.*)$ index.php [L]
If MultiViews are enabled, then that may interfere with your rule. Try adding "-MultiViews" to your Options directive. Also, if you are on Apache 2.x, be aware that AcceptPathInfo may be interfering with your rule. Finally, "RewriteOptions inherit" may not be set on your server; Try adding that line to your code.
I'm not sure if you've considered this, but be aware that all requests for images, media, external JavaScript, sitemap.xml, labels.rdf, compact privacy policy, and robots.txt files are going to be rewritten to your script; Be sure it can handle those requests, or exclude them from the rewrite.
Jim