如何使DOCUMENT_ROOT在本地主机和Web主机上都能工作? [英] How to get DOCUMENT_ROOT to work on both localhost and web host?

查看:97
本文介绍了如何使DOCUMENT_ROOT在本地主机和Web主机上都能工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WordPress插件,我想在localhost上以及在不做任何修改的情况下进行部署,但是我似乎无法使用一条语句来设置目录的位置.

I have a WordPress plugin that I would like to work on localhost as well as in deployment without modification, but I can't seem to set the location for a directory using one statement.

我想这样做:

$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/wp-content/cache');

虽然可以在网络主机上运行.在本地主机上,它将产生此错误:

While that works on the web host. On localhost it produces this error:

C:/xampp/htdocs/wp-content/cache/a547b8792c3144c98549be23ef1465e7.spc is not writeable

在localhost上,我需要将其设置为此才能起作用:

On localhost, I need to set it to this to get it work:

$feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/mysite/wp-content/cache');

肯定一定有一些东西既可以在localhost上运行,也可以在网络主机上运行!

Surely there must be something that works both on localhost and on a web host!

谢谢.

推荐答案

查看此内容确定插件和内容目录 WP已经有了这个.

Check this out Determining Plugin and Content Directories WP already has this.

这篇关于如何使DOCUMENT_ROOT在本地主机和Web主机上都能工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆