Kaustubh
1 year ago

SSL Problem Treating www and non www different

Posted 1 year ago by Kaustubh

I have windows server and have domain of godaddy. I took SSL from godaddy and apply on my server. My domain gets secure by SSL but problem come when, i redirect from https://www.example.com and logged in it shows dashboard but when i change url to https://example.com it redirect me to login page.

Here is my VHOST file

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/mcpluat/xampp/htdocs/project/public"
    ServerName www.example.com
    ServerAlias example.com
    
    RewriteEngine on
    
    RewriteCond %{SERVER_PORT} 80  
    RewriteRule ^(.*)$ https://www.example.com/ [R,L]

    <Directory "C:/mcpluat/xampp/htdocs/project/public">
      Options Indexes FollowSymLinks Includes ExecCGI
       AllowOverride All
       Require all granted
    </Directory>
</VirtualHost>

.HTACCESS file

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Everything is working perfectly but why it is treating www.example.com and example.com a different domain

Thanks in advance

Please sign in or create an account to participate in this conversation.