Yii Framework Forum: Yii Advanced Application Frontend & Backend Urls - Yii Framework Forum

Jump to content

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

Yii Advanced Application Frontend & Backend Urls

#1 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 26 August 2013 - 12:47 PM

Hi,

I've been following Yii2 since quite some time and after Public Preview thought to give it a try. In particular I liked the advanced application structure and thought to move ahead with it.

However, while installing, realized that accessing frontend & backend is done via
http://example.com/frontend/web/ and http://example.com/backend/web/

Would it be possible to have them as
http://example.com/ (pointing to frontend) and http://example.com/backend/
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,649
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 26 August 2013 - 01:26 PM

It's quite easily to do this by moving the contents of frontend/web to webroot and backend/web to webroot/backend.
You'll also need to modify require() dirs inside index.php

Yet another way is to place all dirs under webroot and edit .htaccess so that webroot will be rewrited to subdir. Kinda tricky though.
God is real unless declared as integer
0

#3 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 27 August 2013 - 12:03 AM

Won't moving frontend/web under webroot and backend/web under webroot/backend merge too application code?

It will mean I'm placing backend directory under frontend/web. right?


.htaccess based solution could be tricky to manage for sure.


Is it that the directory structure is decided to have two separate domain / sub-domains pointing to both the applications?
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,149
  • Joined: 17-January 09
  • Location:Russia

Posted 27 August 2013 - 03:03 AM

Yes, the idea is to have a subdomain for backend.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   mastermunj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 12-July 11

Posted 27 August 2013 - 10:10 AM

@samdark, Thank you. The query is resolved now.

Please close the thread.
0

#6 User is offline   Kartik V 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 289
  • Joined: 29-August 12

Posted Today, 05:55 AM

View Postmastermunj, on 26 August 2013 - 12:47 PM, said:

However, while installing, realized that accessing frontend & backend is done via
http://example.com/frontend/web/ and http://example.com/backend/web/

Would it be possible to have them as
http://example.com/ (pointing to frontend) and http://example.com/backend/

Released a new application template yii2-app-practical to the community that does this automatically.
SchoolToJoin: My first Yii powered website.
Visit my Yii Extensions & Demos and JQuery Plugins page.
0

#7 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,149
  • Joined: 17-January 09
  • Location:Russia

Posted Today, 06:20 AM

It's not recommended to have source code under webroot. You need to add a warning about securing it via webserver config.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#8 User is offline   Kartik V 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 289
  • Joined: 29-August 12

Posted Today, 06:24 AM

View Postsamdark, on 24 April 2014 - 06:20 AM, said:

It's not recommended to have source code under webroot. You need to add a warning about securing it via webserver config.

Not sure I understood. Which source code (can you elaborate)?

Only the index.php will move to webroot (along with the runtime assets folder from the frontend/web). All other structure remain exactly the same as the yii2-advanced app (the same security should hold good IMO). Its only config file locations change.
SchoolToJoin: My first Yii powered website.
Visit my Yii Extensions & Demos and JQuery Plugins page.
0

#9 User is offline   Kartik V 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 289
  • Joined: 29-August 12

Posted Today, 06:42 AM

If you look at the yii2-app-practical directory structure - its exactly same as yii2-app-advanced except that it does the following:

  • moves frontend/web/index.php, favicon, and robots.txt to root.
  • moves frontend/web/assets to root.
  • deletes frontend/web folder
  • carefully changes index.php configuration locations to point to the new relative vendor, common, and frontend paths.

And voila... you can now access frontend from the approot. B)
SchoolToJoin: My first Yii powered website.
Visit my Yii Extensions & Demos and JQuery Plugins page.
0

#10 User is offline   Gizmo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 22-January 12

Posted Today, 02:53 PM

Why not using URL rewrite similar to ZF2 where module application is default even if you don't mention it in the URL. I'm just asking i don't have any idea how it's handled in YII2 because i didn't have enough time to analyze it.
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