使用 URL 重写 Pivotal 来扩展更大的应用程序
我目前正在开发一个其基本结构类似于论坛的网站。我决定不选择使用已建立的 PHP 框架之一(我以前玩过 Rails),部分是为了学习,部分是因为我相信它们从长远来看会阻碍开发。
我想知道构建应用程序时 URL 重写有多重要。动态 URL 真的过时了吗?如果实现 URL 重写,那么也应该实现控制器吗?以后改用URL重写系统会不会很困难?
现在我只有模型和视图之间的分离,并且它可以很好地满足我的目的。尽量让事情变得简单,并随时添加。
你有什么想法?
I am currently working on a site which resembles a forum in its essential structure. I have decided not to opt for using one of the established PHP frameworks (I have played with Rails before), partially to learn, and also partially because I believe they hinder development in the long term.
I wanted to know how important URL rewriting becomes when building an app. Are dynamic URL's really out of fashion. If implementing URL rewriting should one also then just as well implement controllers? Would it be difficult to switch to a URL rewriting system later on?
Right now I only have a separation between Models and Views, and it's working fine for my purposes. Trying to keep things simple and add as I go.
What are your thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议注意重写,但不要在开发时具体实现它。只要确保不创建神秘的 url,以后使用 mod_rewrite 添加应该相对容易。
特别是,我建议使用函数而不是字符串连接来构建链接。然后,当您实现漂亮的 URL 时,您可以轻松修改函数以返回重写的值,而不是实际路径。
I would suggest being mindful of rewriting, but don't specifically implement it as you develop. So long as you make sure not to create arcane urls, it should be relatively easy to add later using mod_rewrite.
In particular, I would recommend building links using a function rather than string concatenation. Then when you implement pretty URLs, you can easily modify the function to return the rewritten values, not the actual paths.
URL 重写很好,因为它看起来更漂亮,并且使用户更容易看到他将要阅读的内容的内容(尽管无论如何这可能在标题中)。有些人认为出于 SEO 的原因重写更好。
尽管如此,重写对于大型应用程序来说并不是关键。我想说的是,没有死链接并使其易于查找内容才是关键,而不是 URL 有多漂亮。
如果说有什么的话,那就是“拥有就好”,实施起来相当简单——这就是为什么现在每个人都这样做的原因。
URL rewriting is nice because it looks prettier, and makes it a tad easier for the user to see what the content he's about to read is about (although that's probably in a header anyway). Some argue that rewriting is better for SEO reasons.
Still, rewriting is NOT pivotal for a large app. I'd say not having dead links and making it easy to find content is pivotal, not how pretty the URLs are.
If anything its just a "nice to have" that is fairly trivial to implement - that's why everyone is doing it these days.
请记住,对于许多用户来说,URL 是 Web 应用程序用户界面的重要组成部分。因此,URL 重写是提高站点可用性的重要工具。
Remember that URLs are an important part of the user interface of your web application for many users. So URL rewriting is an important tool for increasing the usability of your site.