Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On my laptop I have a local apache server running and my WordPress' installations all point to http://localhost/my-site/.

Obviously this fails when I access the site from my phone, due to missing files (localhost points to 127.0.0.1 which is always the device itself).

But how can I fix this? WordPress stores the site url as an absolute url in the database...

share|improve this question
This is not a wordpress question, you need to enable your apache/router to server over an outgoing port (like a regular server) and then you can visit it by ip. – Wyck Nov 23 '11 at 14:08

closed as off topic by Wyck, kaiser, Chip Bennett, Brady Mar 2 '12 at 9:20

Questions on WordPress Answers are expected to relate to WordPress within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

You have to create a host entry for your development server and use this inside WordPress instead of localhost.

Example

Add the following line to your hosts file and reload your dns cache or reboot the system.

127.0.0.1 wp.local

Hostfile locations

For UNIX/Mac: /etc/hosts

For Windows: %SystemRoot%\system32\drivers\etc\hosts

WordPress modification

Use a DB tool (e.g. phpMyAdmin, Sequel Pro) to change the options siteurl and home inside the wp_options table. Replace localhost with the new name wp.local defined in the hosts file.

If you have existing content in WordPress, you also have to search&replace all hardcoded links (e.g. site/article links or pictures).

Apache modification

You will need to add that hostname to your Apache's vhost configuration as well (except it's setup as default site).

share|improve this answer

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