开发者

Wordpress development - local and remote paths

I'm trying to set up wordpress so that relative paths work on both my localhost development and my live site.

I was hoping it was just a matter of changing the "site" URL and "home" URL to http://localhost/ and www.example.com开发者_开发问答, and then links would be relative. However this is not the case, and I think .htaccess complicates the issue.

Eg, if I want to access a file in www.example.com/wp-content/mydirectory I can do this:

$url = '/wp-content/mydirectory/myfile.php'

but on my local site I have to do this:

$url= '/www.example.com/wp-content/mydirectory/myfile.php'

I have a solution by conditionally echoing a var at the start of the path, but it's not always possible to use PHP to accomplish this, for example, in a post or page where the link is in the content.

Does anyone have an elegant solution?


Go to the database and look inside the config table. There's a value for home (and possibly another value called URL, the table is not too big, so give it a quick scan), change that to your local environment for testing and when you're ready, you can change the record in the database and upload to your remote server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜