apache - 重写到新域?用url查询?不工作。 :( help

标签 apache mod-rewrite url-rewriting

我有这个重写规则...

将所有初始请求从 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]

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

https://world.example.com/approvals/?id=b47b5256567

不幸的是,它没有被正确重定向到 web.example.com。相反,它只是转到 web.example.com,而不带查询参数。

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

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

https://world.example.com/approvals/?id=b47b5256567
then
https://web.example.com/approvals/?id=b47b5256567

只需将世界更改为网络并传递查询字符串。

帮助

最佳答案

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

<VirtualHost *>
    ServerName world.example.com
    Redirect permanent / https://web.example.com/
</VirtualHost>

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

关于apache - 重写到新域?用url查询?不工作。 :( help,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1344595/

相关文章:

apache - AJP 连接器不工作? (404 错误)

.htaccess - RewriteRule后如何在地址栏中保留原始jpg

apache - 仅将 SSL 应用于主域 - .htaccess

rewritecond 中的 apache2 mod_rewrite 每个目录请求

php - htaccess 重写规则仅部分有效

url - 如何将我的 url 从 index.php 重写为 sample.php

php - 使用 C++ 向 Apache Web 服务器发送 POST 请求

apache - 在不更改url的情况下通过tomcat显示主页

asp.net-mvc-4 - IIS 重写不适用于应用程序的根目录

php加密的ssl session 数据