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 中包含内容的相对链接路径


基础教程推荐
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01