I have installed Magento in a server say 123.456.10.129
and copy and paste its files to 123.456.241.82
. When I am trying to access Magento from 123.456.241.82
its getting redirected to 123.456.10.129
. How to change the base URL for Magento? Can I keep the same database for both Magento?
The Magento 2 admin URL allows you to access the backend of the store and then edit and manage the administrative tasks. Typically, the default Magento 2 admin URL is “yourdomain.com/magento/admin.”
If you would like to run two identical websites from one database on two separate URL's i.e Staging/Production then you can simply override the default base_url in the database by setting the values in local.xml
found under app/etc
in your secondary server installation.
Under the admin node add the following -
<stores>
<default>
<web>
<unsecure>
<base_url>http://YOUR.URL.HERE/</base_url>
</unsecure>
</web>
</default>
<admin>
<web>
<unsecure>
<base_url>http://YOUR.URL.HERE/</base_url>
</unsecure>
</web>
</admin>
</stores>
Hope this helps with your issue.
Do an update in the table core_config_data
where the path column is equal to http://123.456.10.129/
(Do not forget the trailing forward slash). Change that to what ever your new IP address is like http://123.456.241.82/
(Again, do not forget the trailing forward slash.
A sample query would be like this.
USE database;
UPDATE core_config_data SET value='http://123.456.241.82/' where value='http://123.456.10.129/';
@Mahan 's answer is correct. But you also need to remove the folders in the var\cache folder and files in the var\session folder. Then just refresh the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With