mod_rewrite的为目录到另一台主机 [英] mod_rewrite for directory to another host

查看:154
本文介绍了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:

RewriteEngine叙述在

  的RewriteCond%{} REQUEST_FILENAME!-f

  重写规则^(。*)$ app.php [QSA,L]

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

我想重定向所有访问 http://www.project1.com/foo 以<一个HREF =htt​​p://www.project2.com/bar相对=nofollow> 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?

推荐答案

把下面的行根的.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天全站免登陆