0

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

2 Answers 2

0

I 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!

1
  • hi there! please consider marking your answer as solution so others can see it too :)
    – Diana
    Feb 26, 2021 at 8:36
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.