這是我的htaccess代碼:與htaccess的URL重寫不工作
RewriteEngine On
RewriteRule ^/typo3$ - [L] RewriteRule ^/typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php
RewriteRule ^/([a-zA-Z0-9_-]+)$ http://www.example.com/index.php?id=82&user=$1 [L,R=301]
顯然,我希望這個網址: www.example.com/username 被翻譯成http://www.example.com/index.php?id=82&user=username
這不起作用然而..(在htaccess的這段代碼的結果不是在所有的工作,並得到一個找不到網頁錯誤
如果我改變] + $對於] +代碼的工作,但沒有像我想:?
RewriteEngine On
RewriteRule ^/typo3$ - [L] RewriteRule ^/typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* /index.php
RewriteRule ^/([a-zA-Z0-9_-]+)? http://www.example.com/index.php?id=82&user=$1 [L,R=301]
URL被重寫/重定向到http://www.example.com/index.php?id=82&user=index的結果...正是這樣,用user = index。現在
,如果我刪除重寫規則。*的index.php線,htaccess的再不能在工作中都下去了,導致找不到網頁錯誤...
我花了幾天在搞清楚了這一點,但我絕對沒有線索天..
所以,我只是想www.example.com/username重定向到http://www.example.com/index.php?id=82&user=username
我想通過簡單的匹配(唯一)的用戶名來獲取ID ...我看到沒有其他辦法。但RewriteRules仍然不能在我的服務器上工作。真奇怪。 – 2014-11-06 11:17:50
**通過簡單地匹配(唯一)用戶名來獲得ID。**匹配如何完成? – anubhava 2014-11-06 11:27:43
通過進行SQL查詢比較 – 2014-11-06 13:48:12