Php – .htaccess send requests to a subfolder’s index.php

.htaccessmod-rewritePHP

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.

Best Answer

The answer that fixed my problem is:

RewriteEngine On

Options Indexes FollowSymLinks

RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

It appears that the Multiviews was throwing it off.

Related Topic