1

ほとんどの領域で絶対アドレス指定を使用するスクリプトがあり、相対アドレス指定に変更する必要があります。しかし、ここで私が直面している問題は、たとえば次のような名前のウェブサイトがある場合です。

www.example.com
今、私はphpのリンクをから変更したい

<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" />

<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" />

しかし、私は最終的にこの結果を得ます

<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" />

どこかで何かが間違っていることは知っていますが、まだ機能させることができません..正しいフォーマットに関するヘルプは非常に高く評価されます. 質問のタイトルが不適切でしたら申し訳ありません。

4

3 に答える 3

1

$themeこの URL ' http://www.example.com/themes/in/ ' が含まれています。したがって、URLを次のようにしたい場合は

http://www.example.com/style.cssそれ以外の

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

$theme次に、セクションからを削除しhrefます。

お役に立てれば

于 2013-03-29T11:55:37.903 に答える
1

URL設定から判断:

<?php
$path  = explode('/', $theme);
$theme = end($path);
?>
<link href="http://www.example.com/themes/<?= $theme ?>/style.css" type="text/css" rel="stylesheet" />

これにより、URL が分割され、必要なテーマ名と思われる最後の項目が選択されます。

于 2013-03-29T11:52:40.890 に答える
0

それらは2つの可能な解決策です。

http://www.example.com/   

ORの開始から<?php print $theme; ?>、ベースバスではなくテーマ名のみを含めます。

于 2013-03-29T11:53:05.547 に答える