[英]Apache and Url Rewrite
我有2個主要頁面。 就像這樣
<html>
<body>
<div id='menu'></div>
<div id='content'><?PHP require("content.php"); ?></div>
</body>
</html>
然后,content.php從URL中提取“頁面”,並通過“好頁面” URL檢查它。 如果沒有,則存在默認值。 無論如何,典型的網址看起來像這樣
我正在嘗試使其看起來像這樣
這是我的.htaccess文件所不能使用的,不能100%工作。 它可以拉出正確的頁面,但css文件似乎未上載。 它作為索引和內容位於主目錄的/ css /中。
編輯
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)/(.*)$ /index.php?page=$1&id=$2 [L]
我希望該應用程序能夠擴展。
謝謝!
您將要使用CSS的絕對路徑,或使用base href
,或者如果CSS路徑從根域開始,則可以在/
加上/
前綴。
您的.htaccess很好,但可能需要進行一些微調:
RewriteEngine On
RewriteRule ^(\w)/([0-9]+)/$ /index.php?page=$1&id=$2 [L,QSA]
請嘗試以下.htaccess中的代碼
RewriteEngine On
RewriteRule ^user/([0-9]+)/$ /index.php?page=user&id=$2 [L,QSA]
RewriteRule ^group/([0-9]+)/$ /index.php?page=group&id=$2 [L,QSA]
請嘗試使用以下代碼,您可以在$_GET['page']
獲取值。 然后您可以用/
分割值,然后獲取用戶名,ID等
RewriteEngine On
RewriteBase /project/
RewriteRule ^([A-Za-z0-9]+){0,1}$ index.php?page=%{REQUEST_URI} [L,NC,QSA]
在上面的代碼中,您可能希望將/project/
替換為/
。 它將完美地工作
試試這個.htaccess代碼
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/(.*)$ /index.php?page=$1&id=$2 [L]
現在,您可以通過來直接訪問您的網頁。
www.yourdomain.com/user/1
www.yourdomain.com/group/3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.