我環顧四周尋找答案,沒有運氣。需要.htaccess重寫規則建議
我想要做的就是更換
http://localhost/mysite/superv/something
與
http://localhost/mysite/superv/?p=something
這是我從昨天起想出了最佳配方:
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^(superv/)([^\?/]+)$ $1\?p=$2 [NC]
但它不工作。
我覺得「RewriteBase」啄無關的問題,因爲這條線的工作就像一個魅力:
RewriteRule ^(javascripts/main\.js)$ $1\.php [NC]
編輯:右鍵Rekire,這是一個錯誤,而複製和粘貼代碼。我現在解決了這個問題。
EDIT2:下面是出現在Apache日誌錯誤:
[Tue Mar 20 20:26:01 2012] [error] [client 127.0.0.1]
Request exceeded the limit of 10 internal redirects due to probable configuration error.
Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
我猜問題是 「循環」,我引述:
Looping occurs when the target of a rewrite rule matches the pattern.
This results in an infinite loop of rewrites
那麼,如果你寫入你的'RewriteRule'「superv」,但你試圖用「admin」來管理一個URL,那麼這是行不通的。 – rekire 2012-03-20 17:31:47
請注意,評論者不會被通知編輯。我想知道你正試圖將用戶重定向到一個php文件的路徑。這可能是你的問題。 – rekire 2012-03-20 18:14:01
請勿在替換字符串中轉義字符,例如'$ 1嗎?P = $ 2'。另外你爲什麼[內部]重定向'http:// localhost/mysite/javascripts/main.js'到'http:// localhost/mysite/javascripts/main.js.php'? – TerryE 2012-03-20 20:36:57