Mod-Rewrite or PHP router?

前端 未结 2 613
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 10:03

I am debating routing my requests with one of the two options:

Option 1: simple capture route with Mod-Rewrite and funnel written $_GET route to index.p

2条回答
  •  执笔经年
    2020-12-14 10:25

    Usually in MVC frameworks, this sort of thing is usually best handled by a front controller (named index.php or the like). You use mod_rewrite to then hide index.php from all of the URLs so your users see nice clean paths.

    It's also way easier to handle in PHP than in Apache's rewrite directives. PHP is much more flexible and easier to write/understand. I'm not sure I've ever seen mod_rewrite used as the sole routing engine for any web framework out there, now that I think of it.

    Your second snip of code is the way to go for your rewrite directives.

提交回复
热议问题