简体   繁体   English

IIS上的301 URL编码

[英]301 URL encoding on IIS

So I'm trying to set up 301 redirects on my site and all of new pages use JQUERY tabs, since JQUERY tabs use specific ids to open a new tab I tried setting up my 301's like /folder/file.html#tabId. 因此,我尝试在我的网站上设置301重定向,并且所有新页面都使用JQUERY选项卡,因为JQUERY选项卡使用特定的ID来打开新选项卡,所以我尝试设置301的/folder/file.html#tabId。 So my 301's will actually look something like this: 所以我的301实际看起来像这样:

  • products/productname-overview.html -> /product/productname.html#overview products / productname-overview.html-> /product/productname.html#overview
  • products/productname-features.html -> /product/productname.html#features products / productname-features.html-> /product/productname.html#features
  • products/productname-specs.html -> /product/productname.html#specs products / productname-specs.html-> /product/productname.html#specs

(So all my content will be in a single page now) (所以我所有的内容现在都将放在一个页面中)

I'm currently working on IIS 8 and I understand there are some rules that encode several characters on my 301's, so I also tried encoding my new urls but it seems that when it detects the %, ISS tells me is invalid. 我目前正在使用IIS 8 ,我知道有一些规则可以对301上的几个字符进行编码,因此我也尝试对新的URL进行编码,但是当它检测到%时,ISS会告诉我这是无效的。

  • products/productname-overview.html -> /product/productname.html%23overview products / productname-overview.html-> /product/productname.html%23overview

Error log: A potentially dangerous Request.Path value was detected from the client (%). 错误日志: 从客户端(%)检测到潜在的Request.Path值。

Description: An unhandled exception occurred during the execution of the current web request. 说明:执行当前Web请求期间发生未处理的异常。 Please review the stack trace for more information about the error and where it originated in the code. 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。

Exception Details: System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (%). 异常详细信息: System.Web.HttpException:从客户端(%)检测到一个潜在危险的Request.Path值。

Source Error: An unhandled exception was generated during the execution of the current web request. 源错误:当前Web请求的执行期间生成了未处理的异常。 Information regarding the origin and location of the exception can be identified using the exception stack trace below. 可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。

StackTrace: [HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (%).] System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +12353279 System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +166 StackTrace: [HttpException(0x80004005):从客户端(%)检测到潜在危险的Request.Path值。] System.Web.HttpRequest.ValidateInputIfRequiredByConfig()+12353279 System.Web.PipelineStepManager.ValidateHelper(HttpContext上下文)+166

Is there a way to make a rule for only the "#" character? 有没有一种方法可以仅对“#”字符制定规则? Any suggestions on how to fix this issue? 有关如何解决此问题的任何建议? Thanks! 谢谢!

Instead of redirecting to a fragment, you could pass the value of the fragment in a query string and retrieve it with js. 您可以将片段的值传递到查询字符串中,然后使用js检索它,而不是重定向到片段。 Your redirect entry would look like: 您的重定向条目如下所示:

products/productname-overview.html -> /product/productname.html?fragment=overview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM