重定向一个子域到另一个,但不改变地址栏但不、个子、地址栏、重定向

2023-09-02 09:51:27 作者:夜袭妓男院

我要重定向 subdomain1.domain.com subdomain2.domain.com ,但没有改变ADDRES中地址栏。

I want to redirect subdomain1.domain.com to subdomain2.domain.com but without changing the addres in the address bar.

通过的.htaccess这可能吗?如果没有,会是怎样一种替代解决方案(我用的cPanel)?

Is this possible via .htaccess? If not, what will be an alternative solution (I'm using cPanel)?

我不想使用代理([P])!

I don't want to use a proxy ([P])!!!

推荐答案

除2子域共享文档根目录(或者是其他的子目录中),那么你就不能没有任何形式的代理做,用 [P] htaccess的或使用设置反向代理的ProxyPass (注意,这两种使用mod_proxy的)。有没有替代的解决方案,这是严格的Apache。你可以只使用mod_proxy或者它的一个写一个脚本加载其他子域的网页,并停放在第一个子域,但这是代理,以及,你最好的扩展(如mod_proxy_html),用于处理内部URL重写重定向位置和饼干。的非Apache的解决方案的一个例子是安装子域的文档根目录到另一个和使用mod_rewrite。

Unless the 2 subdomains share a document root (or one is in a subdirectory of the other), then you can't do it without a proxy of any kind, with a [P] in htaccess or setting up a reverse proxy using ProxyPass (note that both use mod_proxy). There's no alternative solution that's strictly apache. You could write a script to load the pages of the other subdomain and park it on the first subdomain, but that's proxying as well, you're better off just using mod_proxy or one of it's extensions (like mod_proxy_html), which handles internal url rewrites of redirect locations, and cookies. An example of a non-apache solution would be mounting one subdomain's document root into the other and using mod_rewrite.