Javascript 从子域引用css和js文件

Javascript 从子域引用css和js文件,javascript,php,html,css,Javascript,Php,Html,Css,我有一个主题网站,它使用自己的样式表和javascript 我想创建多个子域名,使用不同的主题从主网站 当我创建子域并引用子域css和js文件时,它无法找到它 我想子域引用不同的主题比主网站的主题 我的主要网站正在更新中 公共\u html/示例 public_html/example/css public_html/example/css/exm.css 我的子域具有以下层次结构 public_html/example/subdomain/sub1 public_html/example/su

我有一个主题网站,它使用自己的样式表和javascript

我想创建多个子域名,使用不同的主题从主网站

当我创建子域并引用子域css和js文件时,它无法找到它

我想子域引用不同的主题比主网站的主题

我的主要网站正在更新中 公共\u html/示例
public_html/example/css
public_html/example/css/exm.css

我的子域具有以下层次结构
public_html/example/subdomain/sub1
public_html/example/subdomain/sub2

css和js都在
公共\u html/示例/子域
public_html/example/subdomain/css
public_html/example/subdomain/css/exm.css

public_html/example/subdomain/sub1/index.html


因此,我想从sub/index.html的index.html中引用exm.css,如果所有页面都有相同的
index.php
,但只想根据当前子域包含不同的css和Javascript文件,则可以使用
HTTP\u HOST
提取它,然后包含相应的文件。您可以将它们存储在
your.domain.com/sub/js/theme.js
your.domain.com/sub/css/theme.css

PHP:

HTML:



请发一些代码?
$includePath = "/";
// array(0 => "sub", 1 => "example", 2 => "com");
$domainParts = explode(".", $_SERVER['HTTP_HOST']);
$domainPartsCount = count($domainParts);
if ($domainPartsCount >= 3)
    $includePath .= $domainParts[$domainPartsCount - 3] . "/";
<head>
    <link rel="stylesheet" type="text/css" href="<?= $includePath ?>css/theme.css" />
    <script type="text/javascript" src="<?= $includePath ?>js/theme.js"></script>
</head>