I have searched StackOverflow for my answer, but nothing that I have seen seems to work.
I have a framework that sends all requests to an index.php
file. Everything works when I install it in the root of the virtual host:
http://example.com/
http://example.com/home
http://example.com/home/index
The problem happens when I try to install the framework in a subdirectory like:
http://example.com/blog/
Requests like:
http://example.com/blog/home
http://example.com/blog/home/index
All of those requests should be sent to the index.php file that lives in /blog
My current set up is:
http://example.com/index.php
- This file just prints out "we are in the root of the virtual host". The framework is not installed there.
http://example.com/blog
- This works fine
When I try to get to http://example.com/blog/home
I get the root index.php
file, not the frameworks. I get the message "we are in the root of the virtual host".
I have the following .htaccess
file located at http://example.com/blog/.htaccess
.
RewriteEngine on
Options Indexes FollowSymLinks -MultiViews
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Any help is greatly appreciated.
The answer that fixed my problem is:
It appears that the Multiviews was throwing it off.
Means "if not js or ico..." forward to
index.php
.So, in essence, your
/blog
level.htaccess
is saying if it's not an image or CSS file redirect it to/blog/index.php
.Try it without the forward slash.
Are the requests that you're testing with for items that don't actually exist in the directory? These lines:
Mean that any requests for a file or directory that exists won't be rewritten.