在.htaccess中重定向时,&符号会转义

时间:2019-04-11 08:02:56

标签: apache .htaccess redirect mod-rewrite

我希望Apache服务器将URL https://frot.io/cv重定向到https://latexonline.cc/compile?git=https%3A%2F%2Fgithub.com%2Ffrot-io%2Fcurriculum-vitae&target=main.tex&command=xelatex,从而在.htaccess中插入 Redirect 语句:

RewriteEngine On 
RewriteBase /

# Redirect to https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

# Redirect frot.io/cv
Redirect 301 "/cv" "https://latexonline.cc/compile?git=https%3A%2F%2Fgithub.com%2Ffrot-io%2Fcurriculum-vitae&target=main.tex&command=xelatex"

但是,这会重定向到https://latexonline.cc/compile?git=https%3A%2F%2Fgithub.com%2Ffrot-io%2Fcurriculum-vitae%26target%3Dmain.tex%26command%3Dxelatex(两个和号和等号被转义),从而导致错误。

如何防止Apache逃脱URL中的&符号?

我也试图逃避那些(%26%3D),但是我也被错误地重定向了。

1 个答案:

答案 0 :(得分:0)

我在支持人员的帮助下将其解决:

RewriteEngine On
Redirect 301 /cv https://latexonline.cc/pending?git=https%3A%2F%2Fgithub.com%2Ffrot-io%2Fcurriculum-vitae&target=main.tex&command=xelatex
RewriteBase /
...