Yiiboilerplate Common Htaccess
Posted 26 March 2013 - 07:52 AM
The boilerplate documentation encourage you to put files that are shared between frontend and backend in the common directory.
However, the common directory contains an .htaccess file with "deny from all".
So how do you access your files in common?
I see the index.php file uses include_once, but that is used for individual files, not for an entire directory.
Posted 26 March 2013 - 09:40 AM
'import' => array( 'common.components.*', 'common.extensions.*', 'common.models.*', ),
Posted 26 March 2013 - 10:29 AM
I added myfiles folder:
'import' => array( 'common.components.*', 'common.extensions.*', 'common.models.*', 'common.myfiles.*', ),
But, it still does not work, unless I put a .htaccess file with "allow from all" in myfiles.
So why is it working for common.models? There is no .htaccess file in the models folder.
Posted 26 March 2013 - 10:38 AM
Yes I saw the .htaccess in the Yii folder. And index.php can still access files in Yii by using:
require_once('common' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'Yii' . DIRECTORY_SEPARATOR . 'yii.php');
But that is for a single file.
I want to be able to access all files in common.myfiles.* so that I can store all my shared code and views there. I don't want to require_once() all the files individually.
Posted 27 March 2013 - 09:53 AM
Yes, I have just read a wiki that sort of goes into the same direction as your question.
It looks as if my problem pertains to the KIND of file I want to access.
So I want to put them under common/myfiles/css and common/myfiles/views, etc.
But I cannot access them unless I put a .htaccess with "allow from all" in the myfiles folder - which I don't want to do because I have read:
"Deny from all" in a .htaccess file, residing in a directory would deny access to that directory’s contents.
But it does not prevent a PHP script on the server from accessing that content through
include() and require(), as those requests go through the file system, not through the Web server.
So this means I should be able to access common/myfiles/* even without "allow from all".
But how to do it? I read that "import" works on classes - so probably not on css and views.
Posted 27 March 2013 - 10:37 AM
There are many CSS/scripts/images bundled with Yii, and they are under the protected directory. In order to allow the web server to access them, Yii will "publish" them under the "assets" folder using CAssetManager. And the "common" directory of YiiBoilerplate is assumed to be a protected directory.
So, what you want to do will be ...
1) Store CSS/scripts/images under your "common.myfiles" directory. And publish them under "backend.www.assets" and "frontend.www.assets".
2) Store CSS/scripts/images under your "common.myfiles" directory. And create symbolic links in "backend.www" and "frontend.www".
Posted 18 June 2013 - 05:55 PM
I do have backend where Admins logs in and Posts some Text accompanied by images usong redactorjs. Well they work fine with backend. I'm now struggling on how non-registered users who cannot access backend but front end will access the images. They can see Text since it is in the database but not images which are under backend/www/uploads.
Any idea on how to resolve such problem? I want to display images as well from front end that are stored in backend!
Posted 19 June 2013 - 06:02 AM
There seems to be 2 easy solutions.
1) Save images in the front end when you are in the back end.
If the both of the ends are the virtual hosts of a single server, and if the server configuration is under your control, then you can create a symbolic link to a front end directory in the back end.
(I mean, linking "/backend/www/upload" to "/frontend/www/updload")
2) Load images in the back end when you are in the front end.
You should be able to access the image files in the back end by specifying the full url of them even when you are in the front end.