htaccess的子域名重定向到端口,同时保持原始地址 [英] htaccess subdomain redirect to port while keeping original url
问题描述
我有麻烦这正常工作,我想要做的是使 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]
这篇关于htaccess的子域名重定向到端口,同时保持原始地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!