更改 PHP 中包含内容的相对链接路径
我的服务器根目录中有一个 PHP 文件.. index.php .. include
的 ..DIR/main.php
I have a PHP file at my server root.. index.php .. which include
's .. DIR/main.php
现在 .. DIR/main.php .. 有很多附近文件的相对链接.
Now .. DIR/main.php .. has relative links to many nearby files.
所有相关链接都断开了.
All the relative links are broken.
我可以通过什么方式更改链接的相对 URL 基本路径?
Any way I can change the relative-URL base path for links?
...所以 DIR/main.php 的包含内容将其所有到 friend1.php 的链接都更改为 DIR/friend1.php强>.
... so the included content of DIR/main.php has all its links to friend1.php changed to DIR/friend1.php.
这不是关于包含的,这是关于整体更改 ahref 链接.
This in NOT about include's, this is about CHANGING ahref links en-masse.
推荐答案
html中的base标签适用于相对链接.有关如何使用它的示例,请参阅 w3schools.
The base tag in html works for relative links. See w3schools for an example on how to use it.
相关文章