2

我使用以下代码将https://live.example.com映射到http://example.com/api

Options +FollowSymLinks

RewriteEngine On 

RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^live\.example\.com [NC]
RewriteRule (.+)$ "http://example.com/api/$1" [L,P]

以下网址:

https://live.example.com/userlinks/xml/John%20James/MvPjeUTo15/

假设映射到:

http://example.com/api/userlinks/xml/John%20James/MvPjeUTo15/

相反,它将其映射到:

http://example.com/api/userlinks/xml/John

所以它似乎在空间上削减它。我正在使用 Codeigniter 框架,但我不确定问题是否存在。

在 url 栏中使用%20或仅使用空格不会产生不同的结果。

任何人有任何想法和/或解决方案为什么会发生这种情况?

非常感谢,

4

2 回答 2

2

我把它修好了:

添加到 apache2.conf (httpd.conf):

RewriteMap escapemap int:escape 

.ht 访问:

Options +FollowSymLinks

RewriteEngine On 

RewriteCond %{HTTPS} =on
RewriteCond "%{HTTP_HOST}" "^live\.domain\.com" [NC]
RewriteRule "(.*)$" "http://domain.com/api/${escapemap:$1}" [L,P]

来源: http: //www.nabble.com/Re%3A-Re-users%40httpd--writeRule%2C--P--and-space-on-URL-p15632475.html

于 2009-01-02T14:56:44.330 回答
0

什么对我有用,而无需修改 httpd 文件:

RewriteRule ^(.+) http://domain.com/api/$1 [R=302,NC]

请注意规则如何不捕获行尾。

于 2013-03-08T00:55:16.163 回答