如何去除 url 变量 [英] How to strip out a url variable
问题描述
我有一个 url.LoginID,当用户单击登录链接时,我想将其从地址栏中删除.必须是书签,不能是表单提交.
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.
问:如何从 Index.cfm 中删除 ?LoginID?LoginID=XYZ&AssignmentID=123
Q: How do I remove ?LoginID from Index.cfm?LoginID=XYZ&AssignmentID=123
大概是这样的:
<cflocation url="#cgi.SCRIPT_NAME#?#cgi.QUERY_STRING#" addtoken="no">
推荐答案
看来你走对了.
如果 loginID 是查询字符串中的唯一内容,您可以简单地 cflocation 到没有查询字符串的目标页面.
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#">
这实际上删除了 loginid 和所有内容,直到字符串的 en 或下一个 URL 变量.
This essentially removes loginid and everything until either the en of the string or the next URL variable.
这篇关于如何去除 url 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!