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://domain/
http://domain/home
http://domain/home/index

The problem happens when I try to install the framework in a subdirectory like:

http://domain/blog/

Requests like:

http://domain/blog/home
http://domain/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://domain/index.php - This file just prints out 'we are in the root of the virtual host' The framework is not installed there.

http://domain/blog - This works fine

When I try to got to http://domain/blog/home I get the roots 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://domain/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.

Regards,

Justin

link|improve this question
feedback

migrated from stackoverflow.com Mar 11 '10 at 18:34

This question came from our site for professional and enthusiast programmers.

5 Answers

RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

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

link|improve this answer
This is what I want. I want all requests, excepted those piped, to go to the index.php page. If I go to domain/blog this works. When I go to domain/blog/home it goes to the domain this is the problem. – mediaslave Mar 11 '10 at 16:30
feedback
RewriteBase /blog

Try it without the forward slash.

link|improve this answer
Nope, that has no effect. Thanks. – mediaslave Mar 11 '10 at 16:46
feedback
up vote 1 down vote accepted

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.

link|improve this answer
feedback

Do you know of anyway with htaccess to disable someone from using your domain to point to their own website on the same server? Ex: they use YOURDOMAIN.com to promote their PHISHING WEBSITE.COM by using this simple URL to send users : YOURDOMAIN.COM/~phishing/file.html

Any help would be greatly appreciated. Thanks

link|improve this answer
feedback

Are the requests that you're testing with for items that don't actually exist in the directory? These lines:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Mean that any requests for a file or directory that exists won't be rewritten.

link|improve this answer
The directory does not exist, but could. – mediaslave Mar 11 '10 at 21:34
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.