如何更改网站根目录

发布于 2024-09-25 13:50:15 字数 153 浏览 0 评论 0原文

我在整个网站中使用了绝对链接,当我尝试在另一台服务器上的子目录中设置测试版本时,问题就出现了。例如,实时服务器上的文档结构为 /images/image.jpg,但测试文件夹上的文档结构为 /subdirectory/images/image.jpg。

解决办法是什么?干杯。

I have used absolute links throughout my site, the problem comes when I am trying to set up a testing version in a subdirectory on another server. For example, the document structure is /images/image.jpg on the live server, but /subdirectory/images/image.jpg on the testing folder.

What is the solution? Cheers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寻梦旅人 2024-10-02 13:50:15

肮脏而快速的答案:使用符号链接

将所有内容移动到/images/并运行此:

 ln -s /images/ /subdirectory/images/

干净且较慢的答案:在常量文件上定义常量。到处使用常量作为文件位置的后缀。更改实时最佳答案的常量文件

:复制环境(dev = live)。

dirty and fast answer: use symlink

Move everything to /images/ and run this :

 ln -s /images/ /subdirectory/images/

clean and slower answer: define a constant on a constant file. Use constants everywhere as a suffix to file location. Change the constant file for live

Best Answer: replicate environments (dev = live).

凝望流年 2024-10-02 13:50:15

不要使用子文件夹,而使用子域。即使在共享主机上,您通常也可以进行设置。整个过程只需几分钟,而且您无需修改​​项目中的任何内容。

Don't use subfolders, use subdomains instead. Even on shared hosting you typically have the ability to set these up. It takes all of a few minutes, and you dont have to modify anything in your project.

乖乖哒 2024-10-02 13:50:15

只需执行 var_dump($_SERVER) 即可,它是一个存储大量服务器相关变量的数组。您会想出类似的内容

$_SERVER['SERVER_NAME']
$_SERVER['SERVER_PROTOCOL']

http://php.net/manual/en /reserved.variables.server.php 用于服务器变量列表

Just do a var_dump($_SERVER) which is a array that stores a lot of server related variables. You will come up with something like

$_SERVER['SERVER_NAME']
$_SERVER['SERVER_PROTOCOL']

read http://php.net/manual/en/reserved.variables.server.php for a list of SERVER vars

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文