简体   繁体   English

htaccess将子域重定向到另一个域的子文件夹

[英]htaccess redirect subdomain to subfolder of another domain

I'm using .htaccess to proxy redirect the content of a subdomain to a subfolder of another domain as: www.domain1.com/support will show content from site1-support.domain2.com 我正在使用.htaccess代理将子域的内容重定向到另一个域的子文件夹,如下所示: www.domain1.com/support将显示site1-support.domain2.com中的内容

While keeping the address bar showing hxxp://www.domain1.com/support. 同时保持地址栏显示hxxp://www.domain1.com/support。

To do this, I've created an empty folder called "support" under www.domain1.com and add this to .htaccess: 为此,我在www.domain1.com下创建了一个名为“ support”的空文件夹,并将其添加到.htaccess中:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?support/(.*)$ http://site1-support.domain1.com/$1?proxy=http://site1-support.domain2.com [P]
</IfModule>

This works, but whenever there is ? 这可行,但是只要有的话? in the url it doesn't show the page, such as hxxp://www.domain1.com/kb.php?article=1 网址中没有显示该页面,例如hxxp://www.domain1.com/kb.php?article = 1

Any help from htaccess gurus out there? htaccess大师有什么帮助吗?

If you want to forward the article=1 with the RedirectRule you should add the QSA flag. 如果要使用RedirectRule转发article=1 ,则应添加QSA标志。

RewriteRule ^/?support/(.*)$ http://site1-support.domain1.com/$1?proxy=http://site1-support.domain2.com [QSA,P]

Hope it helps, and that I understood your question correctly. 希望对您有所帮助,并且我已正确理解您的问题。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM