解決啟用 mod_rewrite 出現的 Bad request!

Bad request!
Your browser (or proxy) sent a request that this server could not understand.

If you think this is a server error, please contact the webmaster.

Error 400
localhost
05/18/07 18:18:48
Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.1


這種狀況通常是 RewriteBase沒設好。

如果程式執行的網址是 http://localhost/project/abc/ 的話,在 .htaccess 裡面加入:

RewriteBase /project/abc/

這樣就會正常了。

2 comments On 解決啟用 mod_rewrite 出現的 Bad request!

  • 原來如此。 🙂

    另外現在很多 Framework 都會有類似 url_rewrite 的功能,協助我們處理網址的最佳化。舉 Zend Framework 來說,我們只需要在 .htaccess 中將所有 request url 轉給 index.php ,那麼就可以在程式裡透過 Router 自行處理關於 rewrite 的部份;當然 rewrite base 幾乎也能完全自動化產生,只有較特別的情況會需要我們手動管理。

    這樣的好處是 Porting 到其他平台 (例如 IIS + ISAPI_Rewrite) 的轉換成本就會比較低,因為不會再把所有 rewrite rule 綁在 .htaccess 上。

  • NEO大,

    不好意思, 佔個版面…….
    近日有再MAIL跟您確認電子報系統的問題. 不過還沒有收到回覆.
    不知是漏信了, 還是您最近較忙, 如果有消息的話, 再麻煩通知我一下囉.^^ 謝謝.

    Weikai.

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar