Apache 虚拟主机 url 从一个域重定向到另一个域而不在浏览器中显示 url
Apache virtual hosting url redirect from one domain to other domain without showing the url in the browser
Apache 虚拟主机 url 从一个域重定向到另一个域而不在浏览器中显示 url?
那不是重定向,那叫反向代理。
示例:
ProxyPass /url-path/ http://backend.example.com/url-path/
这会将对/url-path/whatever的所有请求反向代理到指定的服务器后端
更多信息请访问:
http://httpd.apache.org/docs/2.4/mod/mod_proxy.html
http://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
不,如果您的站点位于不同的服务器上,则无法使用 .htaccess 执行此操作。这样做会带来很大的安全漏洞,想象一下如果有人在银行网站上这样做。
但是,如果两者托管在同一台服务器上,请在您的 .htaccess 文件上尝试此操作:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^http://www.domain1.com$
RewriteRule (.*)$ http://www.domain2.com [P]
</IfModule>
如果您同时拥有这两个域,则可以通过域名转发来实现。检查您的注册商中的选项(可能是 godaddy,或像 cloudflare 这样的 dns 管理器)。
Apache 虚拟主机 url 从一个域重定向到另一个域而不在浏览器中显示 url?
那不是重定向,那叫反向代理。
示例:
ProxyPass /url-path/ http://backend.example.com/url-path/
这会将对/url-path/whatever的所有请求反向代理到指定的服务器后端
更多信息请访问:
http://httpd.apache.org/docs/2.4/mod/mod_proxy.html
http://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
不,如果您的站点位于不同的服务器上,则无法使用 .htaccess 执行此操作。这样做会带来很大的安全漏洞,想象一下如果有人在银行网站上这样做。
但是,如果两者托管在同一台服务器上,请在您的 .htaccess 文件上尝试此操作:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^http://www.domain1.com$
RewriteRule (.*)$ http://www.domain2.com [P]
</IfModule>
如果您同时拥有这两个域,则可以通过域名转发来实现。检查您的注册商中的选项(可能是 godaddy,或像 cloudflare 这样的 dns 管理器)。