我想重定向頁面使用mod_rewrite到一些變量的頁面(使用它們的PHP的$_GET
)。國防部重寫和PHP
舉個例子用幾行:
- 當用戶進入
/c/stg
它重定向到item_show.php?id=$1&f=1
(其中f
是頁號)。 - 當用戶輸入
/c/stg/2
時,它會重定向到show.php?id=$1&f=$2
的第二頁。
我覺得有沒有這些錯誤或誤用在我的文件,但在這裏就是我想:
我想用戶輸入/
string
直接去item_show.php?id=$1&f=1
與$1
是我們串當然...
但是,當我通過從RewriteRule
中刪除/c/
部分來更改我的文件時,它開始在所有其他目錄中發出錯誤,並且不會讀取任何文件(my.css
),即使我已經定義了RewriteCond %{REQUEST_FILENAME} !-f
...
你有什麼建議嗎? 或者我怎樣才能用任何方法使這個系統成爲可能?
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#user
RewriteRule ^u/([^/]+)/?$ profile.php?username=$1 [L,NC]
#marked
RewriteRule ^marked/([^/]+)/?$ item_marked.php?id=$1 [L,NC]
#content
RewriteRule ^c/([^/]+)/?$ item_show.php?id=$1&f=1 [L,NC]
RewriteRule ^c/([^/]+)/([^/]+)/?$ item_show.php?id=$1&f=$2 [L,NC]
的第一個建議:張貼在它這些規則的文件的內容。它是主要的服務器配置還是.htaccess文件? – 2009-04-25 03:40:41
當前.htaccess文件是在這裏:! 有FollowSymLinks RewriteEngine敘述 在 的RewriteCond%{} REQUEST_FILENAME -f 的RewriteCond%{} REQUEST_FILENAME -d #user 重寫規則^ U /([^ /] +) /?$ profile.php?username = $ 1 [L,NC] #marked RewriteRule^marked /([^ /] +)/?$ item_marked.php?id = $ 1 [L,NC] #content RewriteRule^c /([^ /] +)/?$ item_show.php?[L,NC] RewriteRule^c /([^ /] +)/([^ /] +)/?$ item_show.php?id = $ 1&f = $ 2 [L,NC] – jnbn 2009-04-25 03:53:21