Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Kaustubh's avatar

SSL Problem Treating www and non www different

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 webmaster@localhost
    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

0 likes
1 reply
douglasakula's avatar

Create a cname record of www whose value should be your domain name. This way the domain example.com and www.example.com are resolved as one and the same

Please or to participate in this conversation.