%2F -> %252F

如果检索词条里面有‘/’,直接检索会提示,没找到文件。

这时就需要灵活的处理下。

 

I also have a site that has numerous URLs with URL encoded characters. I am finding that many web APIs (including Google webmaster tools and several Drupal modules) trip over URL encoded characters. Many APIs automatically decode URLs at some point in their process and then use the result as a URL or HTML. When I find one of these problems, I usually double encode the results (which turns %2f into %252f) for that API. However, this will break other APIs which are not expecting double encoding, so this is not a universal solution.

Personally I am getting rid of as many special characters in my URLs as possible.

Also, I am using id numbers in my URLs which do not depend on URL decoding:

example.com/blog/my-amazing-blog%2fstory/yesterday

becomes:

example.com/blog/12354/my-amazing-blog%2fstory/yesterday

in this case, my code only uses 12354 to look for the article, and the rest of the URL gets ignored by my system (but is still used for SEO.) Also, this number should appear BEFORE the unused URL components. that way, the URL will still work, even if the %2f gets decoded incorrectly.

Also, be sure to use canonical tags to ensure that URL mistakes don't translate into duplicate content.

 

来源:https://stackoverflow.com/questions/1957115/is-a-slash-equivalent-to-an-encoded-slash-2f-in-the-path-portion-of-a

posted @ 2025-05-09 08:53  profesor  阅读(32)  评论(0)    收藏  举报