Is it better to handle friendly/clean/pretty URLs with mod_rewrite or a language like PHP?

前端 未结 5 826
挽巷
挽巷 2021-02-04 14:55

I\'m developing my first decent-sized PHP site, and I\'m a bit confused about what the \"right way\" (assuming there ever is such a thing) to handle clean/friendly/pretty URLs i

5条回答
  •  清歌不尽
    2021-02-04 15:50

    As far as I can see, any possible performance differences between those methods are really minuscule and relevant only for really, really high-traffic sites.

    I think there is no "best practice" as such, both methods are equally often used. If your project structure allows it, and you're more at home with parsing the URL in PHP (where the rest of your project is), put everything through one controller file, and let your application handle the rest.

    If performance is really of the essence, I suspect that having Apache handle the addresses is faster, because there is no interpreted language in between. (I have no hard data for this, though). But as I said, you're probably best of choosing whichever is going to be most maintainable for you in the long term.

提交回复
热议问题