Yii Framework Forum: Yiiboilerplate Common Htaccess - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yiiboilerplate Common Htaccess Rate Topic: -----

#1 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 338
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 26 March 2013 - 07:52 AM

Hi guys

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.

Thanx
0

#2 User is offline   Lal Zada 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 125
  • Joined: 06-November 12
  • Location:Lahore, Pakistan

Posted 26 March 2013 - 09:40 AM

in ur backend/frontend config/main.php

'import' => array(
            	'common.components.*',
            	'common.extensions.*',
            	'common.models.*',
        	),


Is it fast? Is it secure? Is it professional? Is it right for my next project? Yes, it is

Linkedin Facebook Twitter Google+
0

#3 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,074
  • Joined: 16-February 11
  • Location:Japan

Posted 26 March 2013 - 10:10 AM

It's just because there should be no files in "common" directory that should be accessed directly from the end user. You will find the same .htaccess in "framework" directory of Yii.
0

#4 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 26 March 2013 - 10:25 AM

/* moved from General Discussion */
"Less noise - more signal"
0

#5 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 338
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 26 March 2013 - 10:29 AM

Hi Lal Zada

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.
0

#6 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 338
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 26 March 2013 - 10:38 AM

Hi Softarc,

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.
0

#7 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,074
  • Joined: 16-February 11
  • Location:Japan

Posted 27 March 2013 - 05:26 AM

I'm not sure what you mean by "files".
Do you refer to some image files or css/javascript files that should be directly accessed by the web client?
0

#8 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 338
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 27 March 2013 - 09:53 AM

Hi Softarc

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.

I have lots of css, layouts, views and javascript that I want to use in both frontend and backend.

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.
0

#9 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,074
  • Joined: 16-February 11
  • Location:Japan

Posted 27 March 2013 - 10:37 AM

CSS files, javascript files and image files are requested by the web server directly. They have to be under the public directory. But the layouts and views are not.

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".
0

#10 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 338
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 27 March 2013 - 12:33 PM

OK cool.

But how do I access the layouts and views in the common directory?
0

#11 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 27 March 2013 - 12:36 PM

IMO, layouts and views have absolutely no place in 'common'.
Keep models, components, extensions, widgets, etc. in common - if they are common, that is.
"Less noise - more signal"
0

#12 User is offline   Gerhard Liebenberg 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 338
  • Joined: 07-January 12
  • Location:Stillbay - Western Cape - South Africa

Posted 28 March 2013 - 01:49 AM

OK thanks guys.
0

#13 User is offline   Stefano Mtangoo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 205
  • Joined: 02-January 12
  • Location:Dar es Salaam, Tanzania

Posted 18 June 2013 - 05:55 PM

I have the same problem and have been wrestling for weeks now.
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!

TIA,
Stefano
And God said, Let there be science...and it was so!
Training Manager Written in Yii here
0

#14 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,074
  • Joined: 16-February 11
  • Location:Japan

Posted 19 June 2013 - 06:02 AM

Hi Stefano,

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users