(Not allowed to post links, so please assume all instances of domaincom is an actual domain)
Application hosted on domaincom
$this->createUrl( '/admin' );
User clicks admin link and is taken to domaincom/admin
$this->createUrl( '/products' );
User clicks product link and is taken to domaincom/admin/products instead of the expected domaincom/products
Strangely, on the staging server, when clicking on products, the user is taken to the expected domaincom/products url but when the code is pushed to production, we start seeing this issue.
I’ve asked my client to provide PHP version differences, so in the meantime, if someone knows what the issue might be here, please enlighten me.
The actions simply get data from model and render view - no redirections, etc
Layout code
<?php if ( ! Yii::app()->user->isGuest ): ?>
<nav id="main-nav">
<ul class="l_tinynav1">
<li<?php echo Yii::app()->controller->id === 'admin' ? ' class="active"' : ''; ?>>
<a href="<?php echo $this->createUrl( '/admin' ); ?>">Home</a>
</li>
<li<?php echo Yii::app()->controller->id === 'products' ? ' class="active"' : ''; ?>>
<a href="<?php echo $this->createUrl( '/products' ); ?>">Products</a>
</li>
<li<?php echo Yii::app()->controller->id === 'services' || Yii::app()->controller->id === 'faq' ? ' class="active"' : ''; ?>>
<a href="#">Content</a>
<ul style="display: block;">
<li><a href="<?php echo $this->createUrl( '/services' ); ?>">Services</a></li>
<li><a href="<?php echo $this->createUrl( '/faq' ); ?>">FAQs</a></li>
</ul>
</li>
<li><a href="<?php echo $this->createUrl( '/admin/logout' ); ?>">Logout</a></li>
</ul>
</nav>
<?php endif; ?>
Note
The servers use nginx proxy_pass directive to setup a reverse proxy
So I have to define requests[‘hostInfo’] in the config file like this:
'components' => array
(
'request'=>array
(
'hostInfo'=>'domaincom'
),
Might be related