我想開始使用mod_rewrite,所以我可以使用友好的URL在未來。我測試所有在我的本地主機開發。環境,但是,我沒有任何運氣讓模塊工作!mod_rewrite錯誤:[客戶端127.0.0.1]文件不存在
我模塊已啓用(阿帕奇重新啓動):
LoadModule rewrite_module modules/mod_rewrite.so
模塊文件夾下存在於我的Apache安裝目錄
我創建了一個在名爲.htaccess文件名爲mod_rewrite.so文件C:/的public_html/
出於測試目的,香港專業教育學院建立了我的第一個規則,像這樣:
RewriteEngine On
# Translate my-product.html to /product.php?id=123
RewriteRule ^my-product\.html$ /product.php?id=123
用於測試目的,該product.php是非常簡單的:
<?php
// display product details
echo 'You have selected product #' . $_GET['id'];
?>
當我加載http://localhost/my-product.html我得到的錯誤:
The requested URL /my-product.html was not found on this server.
當我去查看日誌,我看到:
[Thu Sep 22 02:37:49 2011] [error] [client 127.0.0.1] File does not exist: C:/public_html/my-product.html
它看起來好像根本不能識別.htaccess規則!
我不知道接下來該做什麼,我覺得我已經應用了所有最簡單的規則來開始使用mod_rewrite,但沒有運氣!
幫助!
感謝 馬爾科
第一個做到了!將屬性更改爲全部後,它就起作用了!現在,我的活動網站位於共享主機上,該屬性通常默認情況下在共享主機上啓用? – Marco
是的,通常在大多數託管服務中,這些屬性都將默認設置。所以不用擔心。 – Goysar
你是救世主! –