Magento 2 URL Change
Note: If you are looking to find your Magento admin URL, please review this post>>
Post deployment, we will want and need to change our IP address URLs to a more friendly domain name structure.
e.g. https://example.com
A very quick way that works on our deployment stacks for Magento Open Source are these simple steps from the ubuntu CLI:
We recommend you reset both legacy paths and new paths, plus reset your admin frontname. In our example, our domain name is 245.amistacxdemos.io.
Magento 2.4.0+
sudo php bin/magento config:set web/secure/base_url “https://245.amistacxdemos.io/”
sudo php bin/magento config:set web/secure/use_in_frontend “https://245.amistacxdemos.io/”
Legacy:
sudo php bin/magento setup:store-config:set –base-url=”https://245.amistacxdemos.io/”
sudo php bin/magento setup:store-config:set –base-url-secure=”https://245.amistacxdemos.io/”
Note: Use the trailing “/” and stay consistent with HTTP or HTTPS.
Run our compile script after you finish.
sudo ./amistacx.sh
Backend Admin Reset
sudo php bin/magento setup:config:set --backend-frontname="admin_#####"
Assuming defaults, replace the ##### with your unique frontname value found in the /magento/apt/ect/env.php file.
Note: Failure to reset the Admin frontname value could lead to 404s when attempting to access the admin dashboard.
Then clear your Magento Store cache:
sudo php bin/magento cache:flush
And last, reset permissions to baseline:
sudo chown -R www-data:www-data /var/www/magento
If you are using Redis, flush Redis too:
sudo redis-cli flushall
Verify from CLI:
sudo php bin/magento info:adminuri
Hostname Reset/Update
Another reason we may need to change our Magento store URLs is if you installed a demo store using an IP address, and now want to change to a DNS hostname.
The overall process is still exactly the same as the below video will show. The only addition would be to make sure the vhost server name is updated too! You should be using HTTPS for a production store, and if you are using Let’s Encrypt to get your cert, you’ll need to make sure your vhost is updated using the correct hostname.
Please refer to your aMiSTACX instructions to walk you through the process.