重写子域通过htaccess的当地环境 [英] Rewriting subdomain for local environment via htaccess
问题描述
我需要重写的子域的地方使用htaccess的环境。
I need to rewrite subdomain for local environment using htaccess.
我已经启用了在本地和其工作的虚拟主机。
I have enabled virtual host in local and its working.
重写
<link href="http://cdn.example.com/css.css" rel="stylesheet" type="text/css" />
到
<link href="http://cdn.localhost/css.css" rel="stylesheet" type="text/css" />
我想这样,但它不工作
I am trying this way but its not working
Rewritecond %{HTTP_HOST} ^cdn.example.com [NC]
Rewriterule ^(.*)$ cdn.localhost/$1 [L,NC,QSA]
我只需要重写 http://cdn.example.com
到的http://cdn.localhost
的http://本地主机
是loacted在 D:\瓦帕\的www \例如
http://localhost
is loacted in D:\wamp\www\example
的http://cdn.localhost
是loacted在 D:\瓦帕\的www \ CDN
http://cdn.localhost
is loacted in D:\wamp\www\cdn
请查看并提出任何可能的方式来做到这一点。
Please see and suggest any possible way to do this
感谢。
推荐答案
您错过的http://
在你的目标URI和研究
标志也随之一旦你使用了 HTTP暗示://
的目标网址
You're missing http://
in your target URI and R
flag will also be implied once you use http://
in target URL.
下面的规则应该工作:
Rewritecond %{HTTP_HOST} ^cdn\.example\.com$ [NC]
Rewriterule ^ http://cdn.localhost%{REQUEST_URI} [L,R]
这篇关于重写子域通过htaccess的当地环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!