mod_rewrite 将目录写入另一台主机 [英] mod_rewrite for directory to another host

查看:21
本文介绍了mod_rewrite 将目录写入另一台主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重写并将所有对目录的访问重定向到另一台主机.我正在使用 Symfony2 框架,.htaccess 位于/web 目录(也是虚拟主机的根目录)中,如下所示:

I need to rewrite and redirect all access to a directory to another host. I'm using Symfony2 framework and the .htaccess is in the /web directory (also the root of the virtualhost) and looks like:

重写引擎开启
RewriteCond %{REQUEST_FILENAME} !-f
重写规则 ^(.*)$ app.php [QSA,L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]

我希望所有对 http://www.project1.com/foo 的访问都重定向到 http://www.project2.com/bar

I want all access to http://www.project1.com/foo redirected to http://www.project2.com/bar

如何使用 htaccess 做到这一点?

How can I do that with htaccess?

推荐答案

在 root 的 .htaccess 中放入以下行

Put following line in .htaccess of root

RewriteRule ^foo/(.*) http://www.project2.com/bar/$1 [QSA,L,R=302]

这篇关于mod_rewrite 将目录写入另一台主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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