重写的领域和路径 [英] Rewrite both domain and path
本文介绍了重写的领域和路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要重定向一个特定的网址,如:
www.example.com/test/ex.gif
到
static.example.com/ex.gif
我怎样才能做到这一点在.htaccess?
解决方案
从我的头顶:
重写规则^ HTTP://www.example.com/test/ex.gif$ http://static.example.com/ex.gif [NC,R = 301]
或测试的任何文件:
重写规则^ HTTP://www.example.com/test/(。*)$ http://static.example.com/$1 [NC,R = 301]
意见后修正从贝拉尔迪先生
I want to redirect one specific url like:
www.example.com/test/ex.gif
to
static.example.com/ex.gif
How can i do this in .htaccess?
解决方案
From the top of my head:
RewriteRule ^http://www.example.com/test/ex.gif$ http://static.example.com/ex.gif [NC,R=301]
or to any file in test:
RewriteRule ^http://www.example.com/test/(.*)$ http://static.example.com/$1 [NC,R=301]
Corrected after advice from Mr. Berardi
这篇关于重写的领域和路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文