来自特定域的htaccess页面重定向导致“ ERR_TOO_MANY_REDIRECTS”

如何解决来自特定域的htaccess页面重定向导致“ ERR_TOO_MANY_REDIRECTS”

以下是我的重定向代码。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.alternativedomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^alternativedomain.com$ [NC]
RewriteRule (.*) http://www.primarydomain.com/$1 [R=301,L]

这很好。重定向发生,但结果页面显示如下错误:

此页面无法正常运行www.example.com,将您重定向了太多次。 尝试清除您的cookie。 ERR_TOO_MANY_REDIRECTS

请帮助我!

谢谢。

解决方法

首先,有了所提供的信息,无需进一步的信息就可以提供真正的帮助。

在其他地方发生了其他重定向。您必须检查所有地方,从头开始跟随白兔子。

两个域(带有子域)是否都指向完全相同的docroot? (并因此使用相同的.htaccess)?如果是,没有完整的.htaccess,没有人可以帮助您。检查其中的所有重写规则。

  1. 检查所有重定向以查找.htaccess重写规则,其中(| www).alternativedomain.com指向
  2. 检查所有重定向,以获取www.primarydomain.com指向的.htaccess
  3. 检查Typo3 / DomainRecord重定向中的快捷方式重定向(不知道新的SiteConfig Think是否具有相似的重定向)(因为在Typo3松弛状态下被询问-主要检查您的代码,系统,html,如果不是Typo3,则也是如此)
  4. 检查重定向扩展名重定向(v9 +)(如果已使用)

因此,通常可以检查。也许首先尝试可视化正在发生的重定向。如果所有/公共Internet都可以访问这些域,则可以使用在线重定向检查器获取所有重定向,并最终获得WHO正在重定向的更多信息。 http://www.redirect-checker.org/

产生类似的东西:

>>> http://www.primarydomain.com

> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------

Status: 301 Moved Permanently
Code:   301
Date:   Thu,27 Aug 2020 14:41:52 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Set-Cookie: __cfduid=d3650e5fe5cc4330ddf77efb41010795a1598539311; expires=Sat,26-Sep-20 14:41:51 GMT; path=/; domain=.primarydomain.com; HttpOnly; SameSite=Lax
Expires:    Wed,11 Jan 1984 05:00:00 GMT
Cache-Control:  no-cache,must-revalidate,max-age=0
Location:   https://primarydomain.com/
X-Endurance-Cache-Level:    2
CF-Cache-Status:    DYNAMIC
cf-request-id:  04d1f73fc80000084b58a59200000001
Server: cloudflare
CF-RAY: 5c968e45fb20084b-CDG




>>> https://primarydomain.com/

> --------------------------------------------
> 200 OK
> --------------------------------------------

Status: 200 OK
Code:   200
Date:   Thu,27 Aug 2020 14:41:54 GMT
Content-Type:   text/html; charset=UTF-8
Connection: close
Set-Cookie: __cfduid=d5a1fcf93be3a0b73390c14fc9bacbe601598539312; expires=Sat,26-Sep-20 14:41:52 GMT; path=/; domain=.primarydomain.com; HttpOnly; SameSite=Lax
Link:   <https://primarydomain.com/index.php/wp-json/>; rel="https://api.w.org/",<https://primarydomain.com/>; rel=shortlink
Cache-Control:  max-age=600
Expires:    Thu,27 Aug 2020 14:51:53 GMT
Vary:   Accept-Encoding
X-Endurance-Cache-Level:    2
CF-Cache-Status:    DYNAMIC
cf-request-id:  04d1f74733000008af6ca0a200000001
Expect-CT:  max-age=604800,report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5c968e51dcef08af-CDG

这最终并不涵盖javascript / meta标签重定向,但仍然可以用来解决该问题。依此类推。

否则,如果您可以将其范围缩小到.htaccess(对于两个域来说一个或最终两个),而您自己看不到为什么将其重定向回去,则激活.htaccess RewriteRule日志可能是找到它的实用工具。如果您能够激活它(Apache虚拟主机,而不是htaccess-不幸的是)。

否则,您可以尝试在线htaccess规则检查器。您可以在其中提供/粘贴您的.htaccess文件和“调用”网址。它将告诉您哪些规则匹配,哪些不匹配以及结果如何。

遗憾的是,它们不支持.htaccess中所有可能的功能。

例如:https://htaccess.madewithlove.be/

注意:提供的链接仅是示例,google属于您自己。没有“爱那个”-如果我需要,我用Google搜索检查器,没有将它们添加为书签。有时是一个或另一个;)

直到现在,generell中的这些步骤在过去帮助我找到了重定向不匹配/失败的地方。

,

最后,我得到了答案。

RewriteCond%{HTTP_HOST} ^ www.test.domain.com [NC]

RewriteRule ^(| /)$ https://www.test.domain.com/test-domain/stest-domain/ [R = 301,L]

谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-