我可以有“友好的”url没有在IIS中的URL重写器? [英] Can I have 'friendly' url's without a URL rewriter in IIS?

查看:181
本文介绍了我可以有“友好的”url没有在IIS中的URL重写器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有可用的ISAPI_Rewrite等网址重写器,可以实现以下操作:

Without having a url rewriter such as ISAPI_Rewrite available, is it possible to achieve the following:

我想让用户浏览到 http://www.jjj.com/directory 其中 / directory 实际上不存在。 IIS将用户转移到 not-found.cfm

I would like a user to browse to http://www.jjj.com/directory where /directory does not actually exist. IIS transfers the user to not-found.cfm.

此时,我可以提供 index.cfm ie http: jjj.com/directory/index.cfm

At this point I can serve index.cfm i.e. http://www.jjj.com/directory/index.cfm.

网址将显示正常,即使目录或 index.cfm 不存在。但是我想在URL中不能有 index.cfm

The url will display just fine and the page loads even though the directory or index.cfm doesn't exist. However I'd like to be able to not have index.cfm in the url.

理想:


  1. 请求 http://www.jjj.com/directory

IIS载入 not-found.cfm 作为默认 404 错误处理程序。

IIS loads not-found.cfm as the default 404 errorhandler.

未找到,剥离 CGI.query_string 并使用 cfswitches 将用户引导到适当的控制器功能。可以使用 onMissingTemplate

Not found strips the CGI.query_string and uses cfswitches to funnel the user to the appropriate controller function. May use onMissingTemplate?

网页请求不会在网址中发生变化,网页会以 200 OK

The page request never changes in the URL and the page loads transparently the user with 200 OK status

如果用户请求 http://www.jjj.com/directory/index.cfm 我会 301 重定向到 http://www.jjj.com/directory

If a user requests http://www.jjj.com/directory/index.cfm I would 301 redirect to http://www.jjj.com/directory

目前


  1. 请求到 http://www.jjj.com/directory

not-found.cfm 作为默认 404 错误处理程序。

IIS loads not-found.cfm as default 404 error handler.

未找到<-c $ c> CGI.query_string ,并使用 cfswitches 以使用户到适当的控制器功能。

Not found strips the CGI.query_string and uses cfswitches to funnel the user to the appropriate controller function.

页面请求变为 http://www.jjj.com/directory/index.cfm 200 OK status

The page request changes to http://www.jjj.com/directory/index.cfm with a 200 OK status


推荐答案

您要问如何切割东西,但告诉我们您不允许使用刀或任何类似的刀。

You're asking how to cut something but telling us you're not allowed to use a knife or anything resembling one.

这是我唯一的聪明使用 onMissingTemplate()的想法。

Here's my only clever idea using onMissingTemplate().

GET / directory /

- > 404.cfm

- > < cfinclude template =#cgi.script_name#/ special.cfm/> / code>

- > fires onMissingTemplate()你可以忽略special.cfm位,请求路径找出什么控制器连接到。

GET /directory/
-> 404.cfm
-> <cfinclude template="#cgi.script_name#/special.cfm" />
-> fires onMissingTemplate() where you ignore the "special.cfm" bit and just use the rest of the requested path to figure out what controller to wire up to.

这是一个kludgy黑客,所以我会尽量避免自己。也许如果您解释为什么 ISAPI Rewriting不是一个选项,那么我们可能能够帮助进一步。

This is a kludgy hack, though, so I would try to avoid it myself. Maybe if you explain why ISAPI Rewriting isn't an option, then we might be able to help further.

这篇关于我可以有“友好的”url没有在IIS中的URL重写器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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