0
我想重定向從我的用戶目錄下的如下:mod_rewrite日誌顯示預期的結果,但仍然獲得404?
/ > index.php?module=home
/MODULE/ > index.php?module=MODULE
/MODULE/ACTION > index.php?module=MODULE&action=ACTION
這是我的規則:
RewriteEngine On
# Rewrite to home page.
# Input:
# Output: index?module=home
RewriteRule ^$ index.php?module=home [L,QSA,NC]
# Redirects to a module
# Input: MODULE/
# Output: index.php?module=MODULE
RewriteRule ^(\w+)/?$ index.php?module=$1 [L,QSA,NC]
# Redirects to a module with the specified action
# Input: MODULE/ACTION/
# Output: index.php?module=MODULE&action=ACTION
RewriteRule ^(\w+)/(\w+)/?$ index.php?module=$1&action=$2 [L,QSA,NC]
只是我總是得到一個404
該日誌顯示我什麼我期待:
[perdir /home/james/public_html/mysite/] rewrite 'user/login' -> 'index.php?module=user&action=login', referer: http://localhost/~james/mysite/
[perdir /home/james/public_html/mysite/] add per-dir prefix: index.php -> /home/james/public_html/mysite/index.php, referer: http://localhost/~james/mysite/
這是正確的重寫到所需的URL,並添加用戶目錄,爲什麼404?
從訪問日誌是哪個文件它無法找到:
RewriteBase /~james/mysite/
奇怪的是如何正確地解析URL,但返回404:
"GET /~james/mysite/user/login HTTP/1.1" 404 1130 "http://localhost/~james/mysite/"
你能看到apache訪問日誌並查看它返回404的文件嗎? –
@ D.Kasipovic我已經將它添加到問題的結尾。 – Lerp
正如我所看到的,/ user/login沒有被重定向,但/ user/login /應該是? –