Change relative link paths for included content in PHP(更改 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.
这篇关于更改 PHP 中包含内容的相对链接路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更改 PHP 中包含内容的相对链接路径
- Laravel 仓库 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01