必须使用MVC FrameW来产生干净的URL吗? [英] Must one use an MVC FrameW to produce clean URL's?

查看:252
本文介绍了必须使用MVC FrameW来产生干净的URL吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要托管的主机不支持服务器端网址重写,因此没有第三方工具可以安装重写网址。

The host that I want to host with does not support server side url rewriting, thus no third party tools can be installed to rewrite the url's.

这是Coldfusion 8,在windows上,IIS。

This is Coldfusion 8, on windows, IIS.

我知道的另一个选择是使用一个框架,但我不想采取的路线应用程序工作得很好,因为它是(但是URL)。

The other alternative that I know of is to use a framework, but I do not feel like taking that route (time), for the application works well as it is (but the URL).

可以清除网址是纯CF生成的?
我不需要干净的url的seo,而是它的用户的容易引用他们的页面。例如。 youtube.com/userpage

Can clean urls be generated by purely CF? I do not need the clean url's for seo, rather it will be for the user's easy reference to their page. E.g. youtube.com/userpage

任何糖果?

如果唯一的选择是使用框架,一个与传统的cfml,cfm的& CFC的?

If the only choice is to use a framework, then which one is most compatible with traditional cfml'', cfm's & CFC's? In that there needs to be minimum changes to the code in the conversion from the none frameworked app to become frameworked.

非常感谢您的贡献!

推荐答案

否。您不需要框架或网址重写器即可 http://domain.com/some/url (通知没有index.cfm)。

No. you do not need a framework or URL rewriter to get http://domain.com/some/url to work (notice no index.cfm).

在IIS中,您可以为404错误设置自定义错误页面。使自定义错误页面在您的服务器上执行ColdFusion页面(例如/urlhandler.cfm,404.cfm或index.cfm)。在该页面中,您可以使用cgi.query_string值上的列表方法通过ColdFusion控制自己的路由。 IIS将为您提供类似404的网址; http://domain.com/the/original/网址,您可以将其解析以将访问者路由到所需的活动。

In IIS you can set up custom error pages for 404 errors. Make the custom error page execute a ColdFusion page on your server (/urlhandler.cfm, 404.cfm or index.cfm for example). Within that page, you can control your own routes with ColdFusion by using list methods on the cgi.query_string value. IIS will provide you a url that looks something like 404;http://domain.com/the/original/url which you can parse to route the visitor to your desired event.

<!--- Get URL String --->
<cfset CurrentURL = ListGetAt(cgi.query_string, 2, ";")>
<cfset CurrentURL = Replace(CurrentURL, ":80", "")>
<cfset CurrentURL = Replace(CurrentURL, ":443", "")>
<cfset CurrentURL = Replace(CurrentURL, "403;", "")>
<cfset CurrentURL = Replace(CurrentURL, "'", "", "ALL")>

我们有一个网站每月接收大约一百万访问者,但仍使用此方法运行SES网址。我被震惊,当我被聘用,发现这个现有的代码在网站的核心,并不会选择重复它,但是,如果你有安装重写器或第三方框架的限制(此客户端对网站的限制)

We have a site that receives approx a million visitors a month that is still running SES urls with this method. I was shocked when I was hired and found this existing code at the heart of the site and would not elect to repeat it, but, if you have limitations on installing a rewriter or third party framework (this client placed restrictions on the site) this solution may work for you.

通过使用上述代码,您可以快速了解如何使用CF来动态包含所需的.CFM文件或执行右侧CFC代码,具体取决于您的设置。

By playing with the above code, you can quickly see how you may use CF to dynamically include the .CFM file you want or execute the right CFC code depending on your set up.

这篇关于必须使用MVC FrameW来产生干净的URL吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆