>我的项目文件夹是这样的
*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
所以我设置了我的 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]
我的HTML标题是这样的(视图/标题.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">
所以当我在我的 url 中传递参数器(如 User/2)时,我所有的 CSS 和 js 都不起作用! 我应该在标题中使用绝对链接作为我的链接标签吗.php ? 像:
<link href="<?php echo dirname($_SERVER['PHP_SELF']);?>/css/Fixer.css" type="text/css" rel="stylesheet">
请帮帮我 TNX !
您必须通过在开头添加斜杠来更改路径。
当您访问 www.yourdomain.com/path1/ 时
服务器在 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">