關於PHP偽靜態有關問題

來源:互聯網
上載者:User
關於PHP偽靜態問題!
我的.htaccess 這麼寫:


RewriteEngine on
RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$index.php?action=$1&id=$2


程式碼:


echo '你的Action是:' . $_GET['action'];

echo "
";

echo '你的ID是:' . $_GET['id'];

?>

現在在瀏覽器中輸入:
localhost/page-18.html

但是報錯:

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.


請問怎麼解決?



------解決方案--------------------
RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$index.php?action=$1&id=$2
index.php前應該有空格
------解決方案--------------------
這有啥為什麼啊,
rewriteRule要有原來的url和轉去的url,你沒空格,apache分不清啊,只好發瘋500了
------解決方案--------------------
.htaccess就是apache的功能,不修改.conf不能生效, 不過現在大部分地方都是預設就啟用它

如果你是問能否在php裡實現url分析及路由,Print_r你的$_SERVER, 裡面有幾個變數包含
完整的url,你可以自己寫程式碼分析然後執行不同的代碼

一些開源軟體裡都有相應的實現,可以參考

探討

如果不修改Apache ,還可以實現這個功能嗎?

------解決方案--------------------
探討

如果不修改Apache ,還可以實現這個功能嗎?

代碼迷推薦解決方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.daimami.com/java-web/317.html
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.