【发布时间】:2015-01-14 20:06:37
【问题描述】:
我的项目文件夹是这样的
*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头是这样的(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">
所以当我在我的 url 中传递参数时,比如 User/2,我所有的 css 和 js 都不起作用!我应该在 header.php 中为我的链接标签使用绝对链接吗?喜欢:
<link href="<?php echo dirname($_SERVER['PHP_SELF']);?>/css/Fixer.css" type="text/css" rel="stylesheet">
请帮帮我!
【问题讨论】:
-
在问这个问题之前,您是否尝试过使用绝对链接?
-
是的,它有效!实际上我在 中添加了
并且它工作正常,但我想知道有没有其他方法可以在 htaccess 中修复它?或者在我的标题中使用 标记是不是很糟糕?还是我使用绝对链接更好???哪个更安全!
标签: javascript php html css .htaccess