簡體   English   中英

使用.htaccess為php重寫URL

[英]rewriting url using .htaccess for php

當我嘗試使用.htaccess重寫網址時,我的頁面CSS受到干擾。 我不知道為什么會這樣。 有人請幫忙..

RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ index.php?$1=$2 [L,QSA]

這是不重寫URL的例子

帶有重寫規則

您的CSS來源是相對於當前文檔的。

確保其為絕對URL。

在重寫的情況下,其請求為field / stylesheets / style.css而不是stylesheets / style.css

您的CSS來源應為:

<link href="http://[yoururlhere]/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />

您的道路被打破了。 給出css的絕對路徑,並將一個.htaccess文件放在css目錄中,僅

RewriteEngine Off

在里面

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM