Apache 2.4.43将我的url"? "改为"%3F"

问题描述 投票:0回答:1

我刚刚部署了apache 2.4,我定义了一个虚拟主机标签来重定向到一个特定的url.问题是我的url包括一个"? "字符和Apache改变它为"%3F".这里是我的实际虚拟主机配置标签。

<VirtualHost *:80>
  ServerName http://app2x.example.com

  RewriteEngine On
  ProxyRequests Off
  ProxyPreserveHost On
  ErrorLog "logs/app2x.example.com-error.log"
  CustomLog "logs/app2x.example.com.log" common
  ProxyPass /sib http://172.168.100.3:9097/sib/f?p=103:1
  ProxyPassReverse /sib http://172.168.100.3:9097/sib/f?p=103:1

</VirtualHost>

如你所见,有一个"?"字符的url,但当我测试它,我得到下一个错误。

/sib/f%3Fp=103:1 start: 2020-04-21T17:37:53.992Z duration: 16ms
URLMappingNotFoundException [statusCode=404, reasons=[The request could not be mapped to any database. Check the request URL is correct, and that URL to database mappings have been correctly configured]]

我已经用这个url测试过了。

ProxyPass /sib http://172.168.100.3:9097/

和工作就好了,但我需要重定向到完整的显示的网址。

我正在使用windows 2019服务器STD版64位与Apache 2.4.43和URL我指向是在另一个类似的机器。

我是新的使用Apache,并没有找到一个答案,在谷歌上解决它,任何帮助将被感激。

apache
1个回答
0
投票

我刚刚解决了我的问题(经过几天的google和尝试),我使它的工作,我必须使用RewriteRule如下。

1.) 我的 httpd-vhosts.conf 文件是这样的。

<VirtualHost *:80>
ServerName http://app2x.example.com

RewriteEngine On
RewriteRule ^/sib$ sib/f?p=103:1 [R=301]  # => everything that contains "/sib" redirect to url: "sib/f?p=103:1"
RewriteRule ^/([a-zA-Z0-9]+)$ sib [R=301] # => everything that contains "/any letter or number" redirect it to sib, that, at same time, will redirect it to url: "sib/f?p=103:1"

ProxyRequests Off                         # => so the server does not work as a normal proxy
ProxyPreserveHost On                      # => important to keep url format from oracle apex server, if not, will display errors when using the app because apache will change the deeper url's
ProxyPass / http://172.168.100.3:9097/    # => important do not forget this last "/"
ProxyPassReverse / http://172.168.100.3:9097/
</VirtualHost>

2.) 不要忘记在文件中启用模式重写行。httpd.conf所以之前的配置可以正常使用

Enable this line => LoadModule rewrite_module modules/mod_rewrite.so

就是这样!,祝你编码愉快

Majv

© www.soinside.com 2019 - 2024. All rights reserved.