htaccess file affecting sign in and not not showing rewrite rule when coming from google

My host company created an htaccess file for me and it works great making all of my pages on my site show as https, but when trying to login, it redirects to the home page and starts a new session. Someone suggested that having www. in the htaccess rule may have been causing this. So I changed my htaccess file and took the www. out. Now when I go to my site the login works right away.

The thing is that if I try to access the site through google it still takes me to the www. version and doesn’t redirect the www to not having it. I’m not sure why?

My htaccess file was this…

RewriteEngine On

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

I changed it to:

RewriteEngine On

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

My signin redirect is like this..

$validate = new Validate();
$validation = $validate->check($_POST, array(
    'username' => array('required' => true),
    'password' => array('required' => true)
));

if($validation->passed()) {
    $user = new User();

    $remember = (Input::get('remember') === 'on') ? true : false;
    $login = $user->login(Input::get('username'), Input::get('password'), $remember);

    if($login) {
        Redirect::to('indexSignedIn.php');
    } else {
        $tryagain = "The information you entered did not match our records.";
    }

} else {
    foreach($validation->errors() as $error) {
        echo $error, '<br>';
    }
}

How can I make this so however someone tries to access my site it shows up without the www.?

OR

How can I make my sign in carry forward the www., so that it does not create a new session and redirect me to the home page.


Source: .htaccess

Leave a Reply