Yii Framework Forum: About redirecting while keeping the displayed the URL in browser - Yii Framework Forum

Jump to content

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

About redirecting while keeping the displayed the URL in browser Rate Topic: -----

#1 User is offline   ryonn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 02-January 12

Posted 26 April 2017 - 05:53 AM

Hi there,

I have a unique situation where I have to develop multiple websites, but managed by only 1 Yii MVC folders (or system)

Let the sites be:

domain.com/blue (<-- this is where the /protected folder of Yii resides)
domain.com/red
domain.com/green

The goal that I want to get is that:
if people access domain.com/red/items/one,
the request is processed as if it goes to domain.com/blue/items/one,
but the URL displayed in the visitor browser is still domain.com/red/items/one

I want to only have 1 Yii file system instead of spreading it into each folder to make it easy to maintain.


I have played around with the .htaccess at domain.com/ to have something like:


RewriteRule ^red/(.*)$ /blue/$1 [P]
RewriteRule ^red/(.*)$ /blue/$1    [QSA,E=ORIG_URI:/$1]




The first line with "P" works fine as intended.
However, the $_SERVER returned does not display any "red" in it, so the system cannot distinguish if the page is accessed from "red" instead of "blue"

The second line has the $_SERVER returned with "red" displayed in the REQUEST_URI, however it returns /blue/index instead of /blue/items/one


I have experimented this for over 8 hours, this is getting frustrating.

Can you please advise what the best practice for this be?
Please help.
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