简体   繁体   中英

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. So my 301's will actually look something like this:

  • products/productname-overview.html -> /product/productname.html#overview
  • products/productname-features.html -> /product/productname.html#features
  • 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.

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

Error log: A potentially dangerous Request.Path value was detected from the client (%).

Description: An unhandled exception occurred during the execution of the current web request. 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 (%).

Source Error: An unhandled exception was generated during the execution of the current web request. 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

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. Your redirect entry would look like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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