如何更改网站根目录
我在整个网站中使用了绝对链接,当我尝试在另一台服务器上的子目录中设置测试版本时,问题就出现了。例如,实时服务器上的文档结构为 /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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
肮脏而快速的答案:使用符号链接
将所有内容移动到/images/并运行此:
干净且较慢的答案:在常量文件上定义常量。到处使用常量作为文件位置的后缀。更改实时最佳答案的常量文件
:复制环境(dev = live)。
dirty and fast answer: use symlink
Move everything to /images/ and run this :
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).
不要使用子文件夹,而使用子域。即使在共享主机上,您通常也可以进行设置。整个过程只需几分钟,而且您无需修改项目中的任何内容。
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.
只需执行 var_dump($_SERVER) 即可,它是一个存储大量服务器相关变量的数组。您会想出类似的内容
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
read http://php.net/manual/en/reserved.variables.server.php for a list of SERVER vars