从子文件夹而不是 Web 根目录运行 CFWheels 站点

发布于 2024-10-25 13:10:42 字数 1350 浏览 1 评论 0原文

我的 CFWheels 站点在 Web 根目录的 subfolder/ 下运行,并且 web.config 与 subfolder/ 位于同一级别。在我的 web.config 中,我有必要的 URL 重写规则来从 URL 中删除“subfolder/index.cfm/”。

当我尝试使用默认的“javascripts”文件夹中包含 Javascript 文件时,出现了问题。

javaScriptIncludeTag("script.js")

默认情况下,cfwheels 在 /subfolder/javascripts/ 中查找 JS 文件。但是,我已从 URL 中删除了 subfolder/,因此对 /subfolder/javascripts/script.js 的请求失败,并显示以下错误消息:

Wheels.ViewNotFound

无法在子文件夹控制器中找到 javascript 操作的视图页面。

虚假。 “javascripts”和“子文件夹”不是操作和控制器。

我相信对 /javscripts/script.js 的请求会成功。如何告诉 cfwheels 不要在子文件夹/中查找 javascripts/ 文件夹?

我无法在文档中找到答案,并且在 CFWheels Google Group 上也没有得到任何回复。我正在寻找答案 例如这个,但特定于 CFWheels。

编辑
IIS 7 web.config 重写:

<rule name="Remove subfolder/index.cfm">
    <match url="(.*)" />
    <action type="Rewrite" url="/subfolder/index.cfm/{R:0}" />
</rule>

如果这条规则不正确,我的问题可能就在这里,我不确定。

linkTo() 实际上也链接到了错误的路径。

linkTo(text="Say Hello", controller="say", action="hello")

输出

<a href="http://mysite.com/subfolder/index.cfm/say/hello">Say Hello</a>

My CFWheels site is running under subfolder/ in the web root, and I have the web.config on the same level as subfolder/. In my web.config I have the necessary URL rewrite rule to remove "subfolder/index.cfm/" from the URL.

My problem arises when I try to include a Javascript file from the default "javascripts" folder using

javaScriptIncludeTag("script.js")

By default, cfwheels looks in /subfolder/javascripts/ for the JS file. However, I've removed subfolder/ from the URL, so a request to /subfolder/javascripts/script.js fails with the following error message:

Wheels.ViewNotFound

Could not find the view page for the javascripts action in the subfolder controller.

Bogus. "javascripts" and "subfolder" are not an action and a controller.

I believe a request to /javscripts/script.js would succeed. How do I tell cfwheels not to look for the javascripts/ folder in subfolder/?

I was unable to find the answer in the documentation, and I haven't gotten any response on the CFWheels Google Group either. I'm looking for an answer such as this, but specific to CFWheels.

edit
IIS 7 web.config rewrite:

<rule name="Remove subfolder/index.cfm">
    <match url="(.*)" />
    <action type="Rewrite" url="/subfolder/index.cfm/{R:0}" />
</rule>

My problem may be here if this rule is incorrect, I'm not sure.

linkTo() actually links to the incorrect path as well.

linkTo(text="Say Hello", controller="say", action="hello")

outputs

<a href="http://mysite.com/subfolder/index.cfm/say/hello">Say Hello</a>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住你手 2024-11-01 13:10:42

我认为问题是您忘记取消 cfwheels 的 javascript 和其他文件夹。

我之前写过这个内容:

http://rip747.wordpress.com/2009/02/23/cfwheels-url-rewriting-in-a-subfolder/

虽然这是针对不同的网址重写器,但我确信您可以移植规则到 IIS7。

i think the problem is that you are forgetting to negate the javascript and other folders for cfwheels.

i did i writeup the covered this a while back:

http://rip747.wordpress.com/2009/02/23/cfwheels-url-rewriting-in-a-subfolder/

though this was for a different url rewriter i'm sure you could port the rules to IIS7.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文