的.htaccess問題我有下面的代碼的.htaccess
裏面:與404和URL重寫
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ 404.php [L]
這樣做的目的是爲了
取下的
.php
擴展url重寫網址,以便
POST
數據將出現在斜槓後面,即如果原始網址爲website.com/sheet?username=bob
,這將被改寫爲website.com/sheet/bob
重定向到一個自定義的404頁面時給出了具體的網址沒有找到
,同時通過WAMP本地開發這個代碼執行罰款,我能看到基於website.com/sheet/<user>
的<user>
值的不同信息。
當我上傳更改到實時站點時,代碼不再有效,並且將website.com/sheet/bob
顯示爲我的自定義404頁面。
是我的.htaccess
錯?對不起,我很沒經驗.htaccess
。
編輯如果我刪除.htaccess
,如果我試圖去website.com/sheet.php
,我得到以下錯誤:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
但這不產生error
文件在我的文檔根目錄雖然,所以我不確定如何看到問題:s
謝謝
如果您完全從服務器上刪除您的htaccess版本,服務器行爲是否有所不同?只是爲了檢查它是否真的是你使用的.htaccess。 – stevenvanc
我刪除了'.htaccess',併發生了一個不同的問題。我在原始文章中添加了一個編輯(用於其他人的可見性) – Sej
首先,您爲什麼要嘗試使用重寫來實現'ErrorDocument'指令的工作......? – CBroe