将php链接替换为静态链接

将php链接替换为静态链接,php,html,Php,Html,我有一个脚本,它在大多数区域使用绝对寻址,现在我需要将它们更改为相对寻址。但是我现在面临的问题是,如果我现在有一个名为www.example.com的网站,我想将php中的链接从 www.example.com <link href="<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" /> <link href="<?php print $theme; ?>css/col

我有一个脚本,它在大多数区域使用绝对寻址,现在我需要将它们更改为相对寻址。但是我现在面临的问题是,如果我现在有一个名为www.example.com的网站,我想将php中的链接从

www.example.com
<link href="<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />

<link href="<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />

根据url设置判断:



他们有两种可能的解决方案,要么你移除

http://www.example.com/   
开始或仅包括
主题名称,而不是带基本浴。

您的
$theme
包含此url“”。所以如果你只是想让url像这样

http://www.example.com/style.css
而不是

http://www.example.com/http://www.example.com/themes/in/style.css

然后从
href
部分删除
$theme


希望这有助于从链接代码中删除
。您应该检查
$theme
变量和why@Chris:请确保您没有在“$theme”vairbale中包含基本路径?它的意思是
$theme包含我从链接代码中删除的链接OK,并添加了/themes/in/styles.css。这起作用了。。。谢谢
<link href="http://www.example.com/http://www.example.com/themes/in/style.css" type="text/css" rel="stylesheet" />

<link href="http://www.example.com/http://www.example.com/themes/in/css/colorpicker.css" type="text/css" rel="stylesheet" />
http://www.example.com/