我有一个.htaccess来重定向我的链接:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
问题是这个.htaccess不允许jquery包含在我的网站中,即使我在<head>
中有这个
<script src="<?php echo WEBROOT;?>views/js/jquery.js"></script>
我已经尝试过了:
RewriteRule ^(views/js/)($|/) - [L]
除了jquery.js所在的文件夹。我也尝试过:
RewriteCond %{REQUEST_URI} !^/js/?$
但没有任何允许jquery !!
有任何解决方案吗?
答案 0 :(得分:0)
这是我的.htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
这就是我包含Jquery的方式:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
或者
<script type="text/javascript" src="<?php echo WEBROOT;?>js/jquery.js"></script>
这是我的index.php页面:
<?php
define('ROOT',str_replace('index.php','' ,$_SERVER['SCRIPT_FILENAME']));
define('WEBROOT',str_replace('index.php','' ,$_SERVER['SCRIPT_NAME']));
require ('core/database.php');
require ('core/controller.php');
require ('core/model.php');
require ('core/view.php');
$url = isset($_GET['url']) ? $_GET['url'] : null;
if (empty($url)) {
require ('controllers/home.php');
$controller = new home();
return FALSE;
}
$params = explode('/', $url);
$file = 'controllers/'. $params[0] .'.php';
if(is_file($file)){
require $file;
$controller = new $params[0]();
$model = $controller->loadModel($params[0]);
if(isset($params[1])){
if (method_exists($params[0], $params[1])) {
$controller->{$params[1]}();
}
else {
echo '<h1>Method '.$params[1].' of Controller '.$params[0].' Not Found</h1>';
}
}
} else {
/* can't find controller*/
echo '<h1>Controller Not Found</h1>';
}
?>
所以Jquery现在只在主页上工作,我的意思是在以下页面中:
localhost/myProject/controller1/method1它不起作用
很抱歉,如果它是一个很长的帖子,但请检查它们