.htaccess RewriteRule,包含url中的斜杠

时间:2021-10-13 10:39:11

What do I need to do to the following rewrite rule with slash in the url?

在URL中使用斜杠,我需要对以下重写规则做什么?

http://www.website.com/p/EQUITY+INVESTMENT+CORP%2FGA

to

http://www.website.com/test.php?name=EQUITY+INVESTMENT+CORP%2FGA

I tried the following way but not working.

我尝试了以下方式,但没有工作。

RewriteRule ^p/(.*) /test.php?name=$1 [PT]

1 个解决方案

#1


Your rule is fine but %2F isn't allowed in URIs by Apache. To allow %2F to be encoded to / you need to add:

您的规则很好,但Apache不允许在URI中使用%2F。要允许%2F编码为/您需要添加:

AllowEncodedSlashes On

in your <VirtualHost...> section or in global context of your Apache config.

在您的 部分或Apache配置的全局上下文中。

#1


Your rule is fine but %2F isn't allowed in URIs by Apache. To allow %2F to be encoded to / you need to add:

您的规则很好,但Apache不允许在URI中使用%2F。要允许%2F编码为/您需要添加:

AllowEncodedSlashes On

in your <VirtualHost...> section or in global context of your Apache config.

在您的 部分或Apache配置的全局上下文中。