如何重定向所有URL在Apache的一个新的领域,除一人外 [英] How to Redirect All urls to a new domain in apache, except one

查看:211
本文介绍了如何重定向所有URL在Apache的一个新的领域,除一人外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重定向一切都在一个网站到一个新的领域,除了一个路径。

I need to redirect everything on one site to a new domain, except one path.

所以domain.com/anything~~V需要去newdomain.com/anything。

So domain.com/anything needs to go to newdomain.com/anything.

但我不想domain.com/services/xml重定向。

But I don't want domain.com/services/xml to redirect.

我试过很多的条件,但没有任何工程。它最终总是重定向,或者将其重定向到其他一些奇怪的路径上的新领域。

I've tried lots of conditions, but nothing works. It always ends up redirecting it, or redirecting it to some other weird path on the new domain.

这不工作:

RewriteCond %{REQUEST_URI} !^/services/xml$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

任何帮助是AP preciated。谢谢你。

Any help is appreciated. Thanks.

推荐答案

我想通了这一点,感谢我的谈话安萨里和一些帮助与托管公司。这个问题似乎是,该网址正在重写到index.php,然后它被后再次重定向。所以:

I figured this out, thanks to my conversation Ansari and some help with the hosting company. The problem seems to be that the the url was being rewritten to index.php, and then it was being redirected again after that. So:

  RewriteCond %{REQUEST_URI} !^/services/xmlrpc
  RewriteCond %{REQUEST_URI} !index\.php$ [NC]
  RewriteRule ^(.*)$ http://www.wikiweightscore.com/$1 [L,R=301]

  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteCond %{REQUEST_URI} !=/favicon.ico 
  RewriteRule ^(.*)$ index.php?q=$1 [QSA] 

本作品为确切使用情况下,我是想。

This works for the exact use case I was wanting.

这篇关于如何重定向所有URL在Apache的一个新的领域,除一人外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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