htaccess的子域名重定向到端口,同时保持原始地址端口、重定向、原始、地址

由网友(执笔画卿颜)分享简介:我有麻烦这正常工作,我想要做的是使http://subdomain.domain.com 重定向到domain.com:8080同时保持原来的网址subdomain.domain.comI have trouble getting this to work properly, what I'm trying to...

我有麻烦这正常工作,我想要做的是使 http://subdomain.domain.com 重定向到domain.com:8080同时保持原来的网址 subdomain.domain.com

I have trouble getting this to work properly, what I'm trying to do is make http://subdomain.domain.com redirect to domain.com:8080 while keeping the original url "subdomain.domain.com"

code到目前为止:

Code so far:

RewriteEngine on
RewriteCond %{HTTP_HOST} subdomain.domain.com
RewriteRule ^(.*)$ http://%1domain.com:8080$1 [L]

由它来完成重定向,但浏览器的URL更改为 http://domain.com:8080 这是不是我所追求的。

Which does the redirect, but browser url changes to "http://domain.com:8080" which is not what I seek.

感谢你在前进!

推荐答案

为了做到这一点,你需要启用的mod_proxy 子域。域 .COM 。一旦启用试试这个规则的的DocumentRoot /的.htaccess subdomain.domain.com

For this to happen you need to enable mod_proxy in subdomain.domain.com. Once it is enabled try this rule in DocumentRoot/.htaccess of subdomain.domain.com:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^subdomain.(domain.com)$
RewriteRule ^ http://%1:8080%{REQUEST_URI} [L,NE,P]
阅读全文

相关推荐

最新文章