[英]Replacing php links to static links
I have script which uses absolute addressing in most areas, now I need to change them to relative addressing. 我有在大多数区域使用绝对寻址的脚本,现在我需要将它们更改为相对寻址。 But then the issue I am facing here is that, if for instance I have a website named
但是接下来我要面对的问题是,例如,如果我有一个名为
www.example.comNow I want to change the links in php from
<link href="http://www.example.com/<?php print $theme; ?>style.css" type="text/css" rel="stylesheet" />
<link href="http://www.example.com/<?php print $theme; ?>css/colorpicker.css" type="text/css" rel="stylesheet" />
to 至
<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" />
But I end up getting this result 但是我最终得到了这个结果
<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" />
I know something is wrong somewhere, but I still can't get it to work.. Any help with correct formatting will be highly appreciated. 我知道某处出了点问题,但仍然无法正常工作。任何有关正确格式的帮助将不胜感激。 Sorry if my title for question is inappropriate.
抱歉,如果我的问题标题不正确。
Judging by the url setup: 通过url设置判断:
<?php
$path = explode('/', $theme);
$theme = end($path);
?>
<link href="http://www.example.com/themes/<?= $theme ?>/style.css" type="text/css" rel="stylesheet" />
This will split the url in pieces and picks the last item which is I think is the theme name you want. 这将把URL分成几部分,并选择最后一个项目,我认为这是您想要的主题名称。
Your $theme
contains this url ' http://www.example.com/themes/in/ '. 您的
$theme
包含此URL'http: //www.example.com/themes/in/ '。 So if you just want the url to be like this 因此,如果您只希望网址像这样
http://www.example.com/style.css
instead of http://www.example.com/style.css
而不是
http://www.example.com/http://www.example.com/themes/in/style.css
then remove the $theme
from the href
section. 然后从
href
部分中删除$theme
。
hope this helps 希望这可以帮助
Their would be two possible solutions, either you remove the 他们可能是两种可能的解决方案,要么您删除了
http://www.example.com/
from starting of <?php print $theme; ?>
从
<?php print $theme; ?>
<?php print $theme; ?>
OR only include theme name rather than with base bath. <?php print $theme; ?>
或仅包含主题名称,而不包含基本名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.