Roel van Dijk
Roel van Dijk

Reputation: 31

Yii2: Subdomain in subdirs redirects to subdir

I wan't to have 2 complete YII2 frameworks running: 1 on the main website and 1 in a subdomain (for testing). For example on www.example.com & staging.example.com.

Everything seems to be working fine but the staging keeps redirecting me to the subfolder (to staging.example.com/staging) and i don't want that! I just want the url to be staging.example.com

The folder setup is:

I have this in htdocs/.htaccess:

Options +FollowSymLinks -MultiViews

RewriteEngine on

RewriteBase /

# STAGING
RewriteCond %{HTTP_HOST} ^staging.example.com$ [NC]
RewriteRule ^((?!staging).*)$ /staging/$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

And this in htdocs/staging/.htaccess:

Options +FollowSymlinks

RewriteEngine on

# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php

Does anybody have an idea what i am doing wrong?

Upvotes: 2

Views: 158

Answers (1)

IStranger
IStranger

Reputation: 2041

You can access virtual host config (on shared hosting)? Just create 2 separate folders:

/htdocs/framework-1/web/
/htdocs/framework-2/web/

And map you domains to these folders using virtual hosts.

Upvotes: 2

Related Questions