cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.0 seems working only on localhost

SOLVED

Magento 2.0 seems working only on localhost

Hi,

I just installed Magento 2.0 on a VirtualBox VM with Ubuntu 15.10, compiling apache .htaccess as adviced and giving directory permissions as described in the installation guide.

It works fine if I access Magento from the VM browser (using http://localhost/magento2, http://127.0.0.1/magento2 or a 2nd level domain), but it seems not working if I try to access from the host machine. If I try to write:

http://192.168.1.6/magento2

it turns into:

https://localhost/magento2/?SID=pm5sih457aov00ojaa6tldqbs1

and then I get a 404 error and it can't load the page.

 

The Vm is connected in bridged mode (IP address is 192.168.1.6) and from the host machine I can easily access the phpmyadmin and phpinfo of the guest machine (i.e.: https://192.168.1.6/phpmyadmin works well!).

 

I tried to install Magento2 several times, first using localhost as "host name", then with 127.0.0.1 and then with a 2nd level domain but the results connecting from the host machine were that the address turned, respectively:

https://localhost/magento2/?SID=pm5sih457aov00ojaa6tldqbs1

https://127.0.0.1/magento2/?SID=pm5sih457aov00ojaa6tldqbs1

https://<2nd level domain>/magento2/?SID=pm5sih457aov00ojaa6tldqbs1

always getting the same error.

 

Some help would be really appreciate.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.0 seems working only on localhost

This is most likely due to the Base URL being set as localhost.

Try changing the Base URL in Magento Admin --> Store --> Configuration --> Web, clear all caches and see if it works.

View solution in original post

3 REPLIES 3

Re: Magento 2.0 seems working only on localhost

This is most likely due to the Base URL being set as localhost.

Try changing the Base URL in Magento Admin --> Store --> Configuration --> Web, clear all caches and see if it works.

Re: Magento 2.0 seems working only on localhost

Thanks for your help.

Trying only to change the base URL replacing it with a domain name, I still got the problem.

So I solved it adding an entry on my host's "hosts" file relating the guest VM IP and the domain name.

Re: Magento 2.0 seems working only on localhost

Go to Document Root/pub

Find .htaccess and add

RewriteCond %{HTTP_HOST} ^abc.com
RewriteRule ^(.*) http://www.abc.com/$1 [L,R=301]

below.

 

This should solve the issue. For me this work in M2.1

 

All the best.