更改 PHP 中包含内容的相对链接路径 [英] Change relative link paths for included content in PHP

查看:39
本文介绍了更改 PHP 中包含内容的相对链接路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器根目录中有一个 PHP 文件.. index.php .. include 的 ..DIR/ma​​in.php

I have a PHP file at my server root.. index.php .. which include's .. DIR/main.php

现在 .. DIR/ma​​in.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/ma​​in.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 中包含内容的相对链接路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆