简体   繁体   English

需要重写 .htaccess 规则以从站点 A 重定向到站点 B,除了 SITA index.php

[英]Need to rewrite .htaccess rule to redirect from Site A to Site B except the SITA index.php

Is it possible to redirect from Site A to site B all the URLs and subdomains except the index.php of site A. I used the below rules but none worked.是否可以将除站点 A 的 index.php 之外的所有 URL 和子域从站点 A 重定向到站点 B。我使用了以下规则,但没有任何效果。

below is what i used to redirect all except the index下面是我用来重定向除索引之外的所有内容的内容

  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^abc.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.abc.com$
  RewriteCond %{REQUEST_URI} ! ^/index.php\
  RewriteRule (.*)$ https://www.newsite.com/$1 [R=301,L]

Currently I m redirecting everything from site A to site B by using code which is working fine with below rule目前,我正在使用符合以下规则的代码将所有内容从站点 A 重定向到站点 B

  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^abc.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.abc.com$
  RewriteRule (.*)$ https://www.newsite.com/$1 [R=301,L]

how can i rewrite it in such a way that site A's index.php open the same as it is and everything else from site A redirects to site B.我怎样才能重写它,使站点 A 的 index.php 以相同的方式打开,并且站点 A 的所有其他内容都重定向到站点 B。

I tried with the one it still doesnt work.我试过一个它仍然不起作用。 everything is going to site b.一切都要去站点b。 And index,php of site A is the same ie www.abc.com I want this to open as it is.和站点 A 的 index,php 是相同的,即www.abc.com我希望它按原样打开。 But www.abc.com/anything to the site B但是www.abc.com/anything到站点 B

Thanks谢谢

Try with below rule, I made an exception in your current rule to ignore only index.php and accept every other matches.尝试使用以下规则,我在您当前的规则中做了一个例外,仅忽略 index.php 并接受所有其他匹配项。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^abc.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.abc.com$
RewriteRule (.*)$ https://www.newsite.com/$1 [R=301,L]

Your previous attempt regardless matching everything.无论匹配所有内容,您之前的尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM