重写到一个新域名?用url查询?不工作 :( 救命

Lou*_*nda 2 apache mod-rewrite rewrite

我有这个重写规则......

将所有初始请求从world.example.com重定向到web.example.com

RewriteCond %{HTTP_HOST} ^world\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^(.*)$ https://web.example.com$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)

哪个效果很好.但是,我的一些应用程序有......

https://world.example.com/approvals/?id=b47b5256567
Run Code Online (Sandbox Code Playgroud)

不幸的是,它没有被正确地重定向到web.example.com.相反,它只是在没有查询参数的情况下访问web.example.com.

如何将所有请求与查询参数一起正确地重定向到web.example.com?

基本上,应该做什么......

https://world.example.com/approvals/?id=b47b5256567
then
https://web.example.com/approvals/?id=b47b5256567
Run Code Online (Sandbox Code Playgroud)

只需将世界更改为Web并传递查询字符串即可.

救命

Gre*_*ill 5

您不需要使用复杂的重写引擎来执行此操作.只需使用Redirect:

<VirtualHost *>
    ServerName world.example.com
    Redirect permanent / https://web.example.com/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

Redirect指令自动保留您重定向后的所有内容.