Part of my work is to create WordPress websites. I usually work on my laptop until I have something good enough to be uploaded to the test server where the client reviews it.
I create a VirtualHost for every new project so I’m always working with a WordPress installation in a domain that looks like http://local.example.com/
, but when the site is uploaded to the test server (not controlled by me), the domain may end being something like http://testserver.com/arbitrary/path/example/
.
The problem is that if I add a custom link to a menu that points to, for example, /events/
, it would work fine locally creating a link to http://local.example.com/events/
, but in the test server, the link will point to http://testserver/events/
, which is obviously not right.
What I want is to give the custom link an URL that would work both on my local environment and the test server.
I already handle the problem of changing the home
and siteurl
WordPress options by:
- changing those settings on the local database
- creating a dump of the database
- update the database on the server
- restoring the local options.
I don’t want to use full URLs for the custom links and having to replace those with the server URL every time I need to update the server’s database.
For links inside the post content, there is a plugin that solves the problem adding two shortcodes: http://wordpress.org/extend/plugins/url-shortcodes/, but I haven’t been able to find something similar for Custom Links.
I was also looking for a solution for this and I found simple one.
This is what you need to place into the URL field:
/index.php/internal-site-name
It works just fine!
Best Regards
Chris