當我添加我的HTaccess重寫規則時,我的scr
屬性與實習生使用的路徑正在被移動。對於第一條規則,所有CSS都可以正常工作,但是當它在鏈接中添加第二個變量時,我的css文件和腳本文件突然被從錯誤的文件夾中調出。重寫規則htacces在錯誤的文件夾中搜索css
Options +FollowSymLinks
RewriteEngine On
RewriteBase /jellyfish_rework/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ index.php?p=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)$ index.php?p=$1&t=$2 [L]
在第一條規則中,一切都很完美。例如當我的鏈接有一個變量(頁面的變量p)時,它的工作原理應該是這樣。這種情況下的鏈接最終是http://localhost/jellyfish_rework/blog
。和css和腳本通常被稱爲
<link href="css/jellyfish.css" rel="stylesheet" type="text/css">
將然後鏈接到我的CSS樣式表。
但是,當我的t(代表標題)變量填充時,例如,我試圖在我的博客中查找特定帖子時,我的整個鏈接都會更改。 Chrome的控制檯將在http://localhost/jellyfish_rework/artikel/Lancering-van-onze-nieuwe-website
輸出如下:
GET http://localhost/jellyfish_rework/artikel/css/font-awesome.min.css Lancering-van-onze-nieuwe-website:23
GET http://localhost/jellyfish_rework/artikel/css/jellyfish.css Lancering-van-onze-nieuwe-website:24
GET http://localhost/jellyfish_rework/artikel/css/bootstrap.min.css Lancering-van-onze-nieuwe-website:22
GET http://localhost/jellyfish_rework/artikel/css/animate.css Lancering-van-onze-nieuwe-website:25
GET http://localhost/jellyfish_rework/artikel/js/custom/knob.js Lancering-van-onze-nieuwe-website:168
GET http://localhost/jellyfish_rework/artikel/js/bootstrap/bootstrap.min.js Lancering-van-onze-nieuwe-website:166
GET http://localhost/jellyfish_rework/artikel/js/custom/wow.min.js Lancering-van-onze-nieuwe-website:167
GET http://localhost/jellyfish_rework/artikel/js/custom/jellyfish.js Lancering-van-onze-nieuwe-website:169
爲什麼加入/article/
我的腳本和CSS的相對路徑?我該如何解決這個問題?
Jep,正如您發佈的那樣,我自己也找到了答案。我在標題標籤中添加了 ',現在它工作正常。謝謝您的幫助! –
Dorvalla
2014-10-28 21:39:45
不客氣,很高興幫助。 – anubhava 2014-10-28 21:42:06