如何清除url变量 [英] How to strip out a url variable
问题描述
我有一个url.LoginID,当用户点击登录链接时,我想从地址栏中将其删除。
问:我如何从Index.cfm中删除LoginID?LoginID = XYZ& AssignmentID = 123
这可能是沿着以下行的:
cflocation url =#cgi.SCRIPT_NAME#?#cgi.QUERY_STRING#addtoken =no>
看起来你是在正确的轨道。 p>
如果loginID是查询字符串中唯一的东西,那么可以简单地使用cflocation到目标页面,而不使用查询字符串。
如果查询字符串中还有其他数据,那么您可以这样做:
< cfset q = reReplaceNoCase (cgi.query_string,LOGINID = [^&] +& ;?,)>
< cflocation url =#cgi.SCRIPT_NAME#?#q#>
这实际上是删除了loginid和所有东西,直到字符串的en或下一个URL变量。 p>
I have a url.LoginID, and I'd like to remove it from the address bar when the user clicks on the link to login. It has to be a bookmark, it can't be a form submit.
Q: How do I remove ?LoginID from Index.cfm?LoginID=XYZ&AssignmentID=123
It's probably something along the lines of:
<cflocation url="#cgi.SCRIPT_NAME#?#cgi.QUERY_STRING#" addtoken="no">
Looks like you are on the right track.
If loginID is the only thing in the query string, you can simply cflocation to the destination page without the query string.
If there is other data in the query string, then you can do something like this:
<cfset q = reReplaceNoCase(cgi.query_string, "LOGINID=[^&]+&?", "")>
<cflocation url="#cgi.SCRIPT_NAME#?#q#">
This essentially removes loginid and everything until either the en of the string or the next URL variable.
这篇关于如何清除url变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!