重写子域通过htaccess的当地环境 [英] Rewriting subdomain for local environment via htaccess

查看:112
本文介绍了重写子域通过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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆