Jump to content
Larry Ullman's Book Forums

Htaccess For Multiple Projects


Recommended Posts


Going through the Yii book, now on the section about 2Hiding the Index File"

I aready had several projects in my web folder, so I put the code for the book in a folder called yiibook.

So to get the index page, I navigate to


I updated my htaccess file to

RewriteRule ^(.*)$ yiibook/index.php/$1

Which I think is correct. Its not entirely clear to me what should happen. At the moment, if I type in http://localhost:90/yiibook/bob

Then it looks like the index page is displayed, and I get a message stating:

Error 404

Unable to resolve the request "bob".


Now I'm getting to my actual question! There is only one htaccess file. If I enter an invalid address in one of my other projects, I will get redirected to the yiibook index file.

For example, lets say I have a project called mytest. If I browse to


I will end up at the yiibook index page.

This would probably not matter in a production website, as there would only be one project. But what do you other developers do when testing on your own PCs?



Link to comment
Share on other sites

The .htaccess file only affects the directory it's in and all subdirectories. You don't say where you put the .htaccess file, but I suspect you put it in the wrong directory. If you put it in the yiibook directory, you shouldn't be seeing these results. 


And your RewriteRule should be specific to that directory:



RewriteRule ^yiibook/(.*)$ yiibook/index.php/$1
Link to comment
Share on other sites

Thanks. On my pc, the htaccess file was in


So I guess I should copy it to


which is where the project is?

Does this mean that each project should have its own htaccess file? So if I set up a yiitest2 project, I should also copy .htacess in there?

Link to comment
Share on other sites


  • Create New...