我有一個使用Mod_Rewrite的.htaccess文件,但如果有人在URL中輸入垃圾,它會產生500錯誤,並顯示我所有的Mod信息。我想阻止它生成500錯誤或將該錯誤轉發到其他頁面。我努力了。Mod Rewrite 500錯誤更正
Error Document 500 /index.php
...但它不工作或重定向。
這裏是我的全部的.htaccess
Options -Indexes
Options +FollowSymlinks
ErrorDocument 500 /index.php
RewriteEngine On
RewriteRule ^BEARS bears.php?page=bears [NC,L]
RewriteCond %{http_host} ^www.domian.org/login.php [NC]
RewriteRule ^(.*)$ https://www.domian.org/login.php [R=301,L]
RewriteCond %{http_host} ^domian.com [NC]
RewriteRule ^(.*)$ http://www.domian.org/$1 [R=301,L]
RewriteCond %{http_host} ^domian.org [NC]
RewriteRule ^(.*)$ http://www.domian.org/$1 [R=301,L]
RewriteCond %{http_host} ^www.domian.com [NC]
RewriteRule ^(.*)$ http://www.domian.org/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/DB/(.+)/page/(.+)$ $1.php?DB=$2&page=$3 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/DB/(.+)$ $1.php?DB=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/(.+)$ $1.php?page=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ $1.php?page=$1 [L,QSA]
也沒有人知道正在從產生的500錯誤。我知道錯誤文件夾中有錯誤文檔,但是此錯誤說「此外,嘗試使用ErrorDocument來處理請求時遇到500內部服務器錯誤錯誤」,並且我無法找到它從哪裏拉。
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html.php
[Thu Sep 22 11:11:40 2011] [debug] core.c(3071): [client 74.84.118.99] redirected from r->uri = /test.html
這個循環在哪裏發生?沒有看到它。
看看服務器的錯誤日誌 - 它會有更多關於錯誤原因的詳細信息。您在瀏覽器中獲得的設計非常模糊,因爲500錯誤細節可能泄漏不應公開的服務器/代碼信息。 –
[Thu Sep 22 10:44:42 2011] [error] [client 74.84.118.99]由於可能的配置錯誤,請求超出了10個內部重定向的限制。如果需要,使用'LimitInternalRecursion'來增加限制。使用'LogLevel debug'來獲取回溯。,引用:http://www.streatoronized.org/ - 當垃圾被放入時,Htaccess必須引起大量的重定向。 –
所以......如果有人輸入垃圾網址,你的重寫就進入了無限循環。你將不得不添加一些東西來處理僞造的url案例,以防止這種情況。 –