VirtualBox WordPress redirects to port 80

旧街凉风 提交于 2019-12-02 19:20:59

问题


I'm running on OSX 10.9.2. I just set up LAMP on Lubuntu in VirtualBox so that I could run a development server through VirtualBox. I changed my /etc/apache2/ports.conf to listen on 8080 instead of 80, and I set up my VirtualBox port forwarding with NAT with the following configuration:

+--------+----------+---------+-----------+----------+------------+
| Name   | Protocol | Host IP | Host Port | Guest IP | Guest Port |
+--------+----------+---------+-----------+----------+------------+
| Apache | TCP      |         | 8080      |          | 8080       |
+--------+----------+---------+-----------+----------+------------+

I can access websites that I have created in /var/www/ such as /var/www/testwebsite/ by accessing localhost:8080/testwebsite on my host machine (the Mac). I'm trying to install a WordPress site on my guest machine. I have followed Digital Ocean's How To Install WordPress on Ubuntu 12.04 and so far it works when I access http://localhost:8080/wordpresssite inside the guest machine (Lubuntu), but when I try to access http://localhost:8080/wordpresssite on my host machine, it redirects to http://localhost/wordpresssite, when then can't be found. How do I fix this issue? Thanks in advance!


回答1:


I ended up following this guide: http://codex.wordpress.org/Changing_The_Site_URL

In my wp-config.php, I added the following two lines

define('WP_HOME', '<host ip address here>:8080/wordpresssite');
define('WP_SITEURL','<host ip address here>:8080/wordpresssite');

It's a little hacky, but it works for my own testing purposes. Also, apparently I've been running into an issue where localhost:8080/wordpresssite redirects to localhost/wordpresssite on Chrome. I think that this might be a caching issue, since it doesn't redirect when I'm in incognito.




回答2:


Access your database and click in the options table.

Change Url to something like : http://10.165.12.167:8080/wp/

Where 8080 is your Apache port.

Clear your browser's cache and try again.



来源:https://stackoverflow.com/questions/23789135/virtualbox-wordpress-redirects-to-port-80

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!