I have this code in .htaccess
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
But it still appears to be the domain.com
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI figured out. In case anyone need it:
I updated the .htaccess file with this code:
RewriteEngine On
# redirect non-www to www urls
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L]
# redirect http to https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
Then I updated the database web/unsecure/base_url and web/secure/base_url to www.domain.com and it worked!
Run the below two commands to change your url
php bin/magento setup:store-config:set --base-url="http://www.dmain.com/"
php bin/magento setup:store-config:set --base-url-secure="https://www.dmain.com/"
Flush the cache
php bin/magento cache:flush