如何删除%的EN codeD斜杠使用的.htaccess规则?斜杠、规则、EN、codeD

2023-09-02 00:50:01 作者:成熟是一种老

我想是进入我的服务器有额外的%252F字符的URL(由于一些历史原因)和他们(301)重定向到相同的URL没有这些字符赶进来的网址。例如: 进来的网址:www.sample.com/content/%252F/foo 之后的.htaccess规则:www.sample.com/content/foo

I want to "catch" incoming URLs that enter my server with extra "%252F" characters in the URL (due to some historical reasons) and redirect them (301) to the same url without these characters. For example: incoming url: www.sample.com/content/%252F/foo after .htaccess rule: www.sample.com/content/foo

我必须要能够赶上这些字符多个实例的URL(在同一个地方),如:www.sample.com/content/%252F/%252F/%252F/foo并删除它们。

I have to be able to catch several instances of these characters in the url (in the same place), like : www.sample.com/content/%252F/%252F/%252F/foo and remove them all.

其中的.htaccess重写规则,我应该使用?

Which .htaccess RewriteRule should I use?

推荐答案

本作品

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)/%2F(.*) /$1$2 [R=301,L]

,但有一个缺点,它确实多个重定向(1每组%252F)

but there is a drawback, it does multiple redirects ( 1 for each group of %252F )