URL handling – PHP vs Apache Rewrite

后端 未结 4 1257
[愿得一人]
[愿得一人] 2021-01-29 09:15

Currently I let a single PHP script handle all incoming URLs. This PHP script then parses the URL and loads the specific handler for that URL. Like this:

if(URI          


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-29 09:46

    The PHP approach is correct but it could use a bit of improvement.

    $file = $uri.".php";
    if (!is_file($file)) { header("Status: 404 Not Found"); require_once(404.php); die(); }
    require_once($uri.".php");
    

提交回复
热议问题