Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用.htaccess将所有流量重定向到主页?避免无限重定向循环?_.htaccess_Redirect_Infinite Loop - Fatal编程技术网

如何使用.htaccess将所有流量重定向到主页?避免无限重定向循环?

如何使用.htaccess将所有流量重定向到主页?避免无限重定向循环?,.htaccess,redirect,infinite-loop,.htaccess,Redirect,Infinite Loop,如何将网站上的所有流量重定向到主页 我们正在为客户重新设计一个网站。在他们当前的主机上,我们删除了他们的旧站点,并建立了一个登录页(http://norbutconstruction.com/)作为他们的主要指标 这是我在.htaccess文件中执行重定向的代码: <IfModule mod_rewrite.c> #Redirect all of the traffic to the temporary landing page RewriteEngine on R

如何将网站上的所有流量重定向到主页

我们正在为客户重新设计一个网站。在他们当前的主机上,我们删除了他们的旧站点,并建立了一个登录页(http://norbutconstruction.com/)作为他们的主要指标

这是我在.htaccess文件中执行重定向的代码:

<IfModule mod_rewrite.c>
   #Redirect all of the traffic to the temporary landing page
   RewriteEngine on
   RewriteRule (.*) /index.php [R=302,L]
</IfModule>

#将所有流量重定向到临时登录页
重新启动发动机
重写规则(.*)/index.php[R=302,L]
当我尝试访问谷歌索引的页面时(http://www.norbutconstruction.com/contact-us)这将导致无限循环。只要我一直在使用.htaccess文件,我似乎记得我编写的规则会导致无限循环。我知道这应该很简单,但我甚至找不到一个如何做到这一点的例子

有没有人对如何让这段代码工作有什么建议,或者对如何避免.htaccess重定向中的无限循环有什么建议?我似乎总是有这些问题

提前谢谢

试试这个:

<IfModule mod_rewrite.c>
   #Redirect all of the traffic to the temporary landing page
   RewriteEngine on
   RewriteCond %{REQUEST_URI} !.*index\.php
   RewriteRule (.*) /index.php [R=302,L]
</IfModule>

#将所有流量重定向到临时登录页
重新启动发动机
重写条件%{REQUEST_URI}*索引\.php
重写规则(.*)/index.php[R=302,L]

我只需添加以下行:RewriteCond%{REQUEST\u FILENAME}-f RewriteCond%{REQUEST_FILENAME}-因为我在文件中引用了一个图像,这个图像也被重定向了。