[英]After I Change my .htaccess my Css An Js not working
my project folders is like this 我的项目文件夹是这样的
*myProject(d:wamp/www/mywebsites/myProject)
@ ajax
@ asset
#all of php functions and database
@ newsPicture
#my post images
@ profilePicture
#user images
@ public
-js
-css
-img
-.htaccess //file
-index.php //file
-User.php //file
-Posts.php //file
@ view
-header.php //include in index.php
-footer.php //include in index.php
so i set my htaccess to this 所以我将我的htaccess设置为此
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Change /Posts.php?id=4 => /Posts/4
RewriteRule ^Posts/([A-Za-z0-9]*)$ Posts.php?id=$1 [L]
#Change /User.php?id=4 => /User/4
RewriteRule ^User/([A-Za-z0-9]*)$ User.php?id=$1 [L]
#Change /Sign.php => /Sign
RewriteRule ^([A-Za-z0-9]+)$ $1.php [L]
and my html header is like this (view/header.php) 和我的html标头是这样的(view / header.php)
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
<link href="css/bootstrap-theme.min.css" type="text/css" rel="stylesheet">
<link href="css/Normalize.css" type="text/css" rel="stylesheet">
<link href="css/Fixer.css" type="text/css" rel="stylesheet">
so when i pass parametr in my url like User/2 all my css and js not working ! 所以当我像User / 2这样在我的URL中传递parametr时,我所有的CSS和JS无法正常工作! should i use absolute Links for my link tag in header.php ?
我应该为header.php中的链接标记使用绝对链接吗? like:
喜欢:
<link href="<?php echo dirname($_SERVER['PHP_SELF']);?>/css/Fixer.css" type="text/css" rel="stylesheet">
please help me tnx ! 请帮我tnx!
You must change paths by adding a slash in the begining. 您必须通过在开头添加斜杠来更改路径。
When you access www.yourdomain.com/path1/ 当您访问www.yourdomain.com/path1/
The server search files in www.yourdomain.com/path1 /css/bootstrap.min.css 服务器在www.yourdomain.com/path1 /css/bootstrap.min.css中搜索文件
<link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<link href="/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet">
<link href="/css/Normalize.css" type="text/css" rel="stylesheet">
<link href="/css/Fixer.css" type="text/css" rel="stylesheet">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.