Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

after basic authentication redirect url modified

I have a site made using Yii framework. I have used HTTP authentication (basic) for user login purpose. It is working fine. And after authentication it redirects to user profile but in url after www part https is appended.eg. https://wwwhttps.example.com/directory/ I have also tried removing https part using .htaccess but no luck. Here is my .htaccess configuration:

#Options +FollowSymLinks 
 IndexIgnore */*
 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

#Basic ldap authentication goes here ...

RewriteCond %{HTTP_HOST} ^wwwhttps\.(.*)$ [NC] 
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]

and the login controller code:

public function actionLogin()
    {
        $this->layout='//layouts/login_layout';
        if(isset($_SERVER['REMOTE_USER']) && $_SERVER['REMOTE_USER']!='')
        {
            $username = $_SERVER['REMOTE_USER'];
            $user = User::model()->findByAttributes(array('username'=>$username)); 

            $ui = UserIdentity::impersonate($user->id);
                if($ui)
                    Yii::app()->user->login($ui, 0);
                    $this->redirect(yii::app()->getBaseUrl(true).'/user/profile');    
    }       
 }

Is it because of basic authentication or anything else? If I don't use basic authentication it works fine.... Please help me. Thanks in advance!!!

like image 739
SkillsIndexOutOfBounds Avatar asked May 25 '26 11:05

SkillsIndexOutOfBounds


2 Answers

Change the .htaccess ldap authentication code to,

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]

So the entire htaccess will look like below,

#Options +FollowSymLinks 
 IndexIgnore */*
 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

#Basic ldap authentication goes here ...
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
like image 106
dev1234 Avatar answered May 27 '26 23:05

dev1234


@Ronit Adhikari: There might be problem with environment variable. You should check that once.

like image 42
Rajeev Kumar Srivastava Avatar answered May 27 '26 23:05

Rajeev Kumar Srivastava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!