Pretty URLs without mod_rewrite, without .htaccess

后端 未结 8 524
轮回少年
轮回少年 2020-12-03 02:27

Without a possibility to access .htaccess I find myself in a creative impasse. There is no mod_rewriting for me. Nevertheless, I want to be able to do the n

相关标签:
8条回答
  • 2020-12-03 02:50

    A quite simple way is to:

    • declare a 404 ErrorDocument (e.g. PHP) in .htaccess
    • parse the query using $_SERVER and see if it corresponds to any result
    • if so replace the HTTP status 404 with status 200 using header() and include index.php
    0 讨论(0)
  • 2020-12-03 02:52

    You can also have urls like

    http://domain.com/index.php/Blog/Hello_World
    

    out of the box with PHP5. You can then read the URL parameters using

    echo $_SERVER['PATH_INFO'];
    

    Remember to validate/filter the PATH_INFO and all other request variables before using them in your application.

    0 讨论(0)
提交回复
热议问题