I would like to move yii framework folder outside

2019-07-20 21:03发布

问题:

I am about to start using Yii framework for some small php projects (I am used to using the code igniter framework previously).

I want to know two things: a) Is it possible to move the /framework folder outside of the web root on linux (centOS in particular) for example: /var/framework_here

b) Could you point me to resources or articles about this and how to actually carry out the task?

I've moved the framework DIR outside of public_html (outside my web root) and tried modifying the paths in the demo projects but they don't function - so I guess I'm doing it wrong.

So far i've only been able to find info on sending the 'protected' directory within a yii project outside normal web access.

Perhaps I've mis-understood, but I thought doing what i want to do would greatly improve system security - that is actually the main reason i want to do this so again I'm open to suggestions/comments.

Thanks

回答1:

You should modify index.php in each demo project. Find line

$yii=dirname(__FILE__).'/../../framework/yii.php';

And change it to something like

$yii='/Absolute path to framework folder/yii.php';


回答2:

You don't need to move it out. All you need to do is put a .htaccess file inside the folder of the framework with the following content:

# Access denied folder
Order Deny,Allow
Deny from all

Doing so you disable the access the folder to anyone outside the server.

For more informations you can give a look here: https://www.google.it/search?q=htaccess+tutorial