Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript htaccess重写规则不加载js css库_Javascript_Php_Css_.htaccess - Fatal编程技术网

Javascript htaccess重写规则不加载js css库

Javascript htaccess重写规则不加载js css库,javascript,php,css,.htaccess,Javascript,Php,Css,.htaccess,我在我的php站点中使用htaccess文件作为漂亮的url。 htaccess文件位于以下位置: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?mod=$1 [QSA,L] 当我写像127.0.0.1/mysite/param1这样的URL时,它意味着; 1

我在我的php站点中使用htaccess文件作为漂亮的url。 htaccess文件位于以下位置:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?mod=$1 [QSA,L]
当我写像127.0.0.1/mysite/param1这样的URL时,它意味着; 127.0.0.1/mysite/index.php?mod=param1,页面加载没有任何问题

但是,当我编写URL 127.0.0.1/mysite/param1**/**时,页面上不会加载css和js文件。因为我的css和js文件在inc/目录中,路径发生了变化。这条路的方向是: param1/inc/jsfile.js


我如何解决它?

这是因为您正在使用资产的相对链接。将此代码添加到html中的
标题
部分

<base href="http://domain.com/mysite/" />

已更新,因为您正在子文件夹中使用它

谢谢巴拿马杰克和奈赫特,你的回答很有帮助

首先;我使用了
标记。尽管路径是正确的,但仍然不起作用。当我在源代码中单击chrome、js和css文件时,我成功地在一个新选项卡中打开了这些文件,但它们并没有影响页面。我没有解决它,我想问题是缓存或类似的东西

所以我尝试了另一种解决方案:文件的完整路径

我在index.php文件顶部定义了基本url,并在需要时使用它:

define("BASE", "http://127.0.0.1/mysite/");

<link href="<?php echo constant("BASE") ?>inc/style.css" rel="stylesheet" type="text/css">
define(“基”http://127.0.0.1/mysite/");

它还经常用于加载带有完整url的CSS/JavaScript文件,例如
example.org/mysite/style.CSS
define("BASE", "http://127.0.0.1/mysite/");

<link href="<?php echo constant("BASE") ?>inc/style.css" rel="stylesheet" type="text/css">