Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

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

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

4 Answers 4

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

share|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
RewriteBase /blog

Try it without the forward slash.

share|improve this answer
    
Nope, that has no effect. Thanks. –  mediaslave Mar 11 '10 at 16:46
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.

share|improve this answer

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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