Why does HttpHeader X-Original-URL not exist on some pages?

☆樱花仙子☆ 提交于 2019-12-11 09:21:45

问题


My site using URL Rewrite to make SEO friendly URLs. This makes self-posting a form back to the same page a little tricky.

However in ColdFusion I do this for the form's action attribute:

<form name="formSortBy" method="post" enctype="multipart/form-data" action="#StructFind(GetHttpRequestData().headers, 'X-Original-URL')#">

</form>

The important part here is the #StructFind(GetHttpRequestData().headers, 'X-Original-URL')# which gets me the URL of the page.

However the X-Original-URL key just doesn't exist on some pages so I get an error from ColdFusion saying:

Cannot find X-Original-URL key in structure.
The specified key, X-Original-URL, does not exist in the structure. 

This is happening when I click to go to the homepage of a section I am in. So X-Original-URL exists if I go to http://www.sitename.com/products/gaming but it won't exist if I go just to http://www.sitename.com/products

Is there anyway to get around this or make it work like I need it to?


回答1:


Sounds like there is an issue between your rewrite rules and CF.

But, there is an easy fix - you can get a form to post to itself by simply not specifying the action attribute.



来源:https://stackoverflow.com/questions/25950039/why-does-httpheader-x-original-url-not-exist-on-some-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!