首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >上次重定向在htaccess是太多了吗?

上次重定向在htaccess是太多了吗?
EN

Stack Overflow用户
提问于 2017-12-19 18:55:34
回答 1查看 35关注 0票数 0

试图确定在访问页面时,最后一次重定向为什么只返回“太多重定向”错误。如果在最后一个页面之后再添加,那么在访问页面时,它们都会得到相同的错误。

代码语言:javascript
运行
复制
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myhrc.biz$ [OR]
RewriteCond %{HTTP_HOST} ^www.myhrc.biz$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofcontractor.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofcontractor.com$ [OR]
RewriteCond %{HTTP_HOST} ^bestroofertx.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.bestroofertx.com$ [OR]
RewriteCond %{HTTP_HOST} ^roofingcompanyhoustontexas.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.roofingcompanyhoustontexas.com$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingreviews.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingreviews.com$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.co$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingonline.co$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingonline.net$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.info$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingonline.info$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.com$
RewriteRule (.*)$ http://www.houstonroofingonline.com/$1 [R=301,L]
ErrorDocument 404 http://www.houstonroofingonline.com/404.html
RedirectMatch 301 ^/residential http://www.houstonroofingonline.com/residential-roofing-houston.html
RedirectMatch 301 ^/about-us http://www.houstonroofingonline.com/houston-roofing-company.html
RedirectMatch 301 ^/residential/insurance-claims http://www.houstonroofingonline.com/roof-insurance-claims-houston.html
RedirectMatch 301 ^/residential/free-roof http://www.houstonroofingonline.com/free-roof-insurance-claim.html
RedirectMatch 301 ^/residential/storm-damage http://www.houstonroofingonline.com/storm-damage-roof-repair-houston.html
RedirectMatch 301 ^/residential/roof-inspection http://www.houstonroofingonline.com/free-roof-inspection-houston.html
RedirectMatch 301 ^/residential/roof-repair http://www.houstonroofingonline.com/roof-repair-houston.html
RedirectMatch 301 ^/commercial http://www.houstonroofingonline.com/commercial-roofing-houston.html
RedirectMatch 301 ^/contact-us http://www.houstonroofingonline.com/contact.html
RedirectMatch 301 ^/blog http://www.houstonroofingonline.com/houston-roofing-blog.html
RedirectMatch 301 ^/roofing-system-complexities http://www.houstonroofingonline.com/roofing-systems.html
RedirectMatch 301 ^/how-to-select-roof http://www.houstonroofingonline.com/how-to-select-a-roof.html
RedirectMatch 301 ^/your-roof-as-a-selling-tool http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-20 14:42:07

上一次重定向导致重定向循环错误/Too许多重定向错误。让我们看看为什么会发生这样的事情:

代码语言:javascript
运行
复制
RedirectMatch 301 ^/your-roof-as-a-selling-tool http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html

实际上,您的RedirectMatch的模式和目标路径是相同的。

Pattern:^/你的房顶销售工具*

目标urlhttp://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html

当您请求example.com/your-roof-as-a-selling-tool时,您的RedirectMatch在第一轮中将url重定向到http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html。在第二轮中,http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html匹配模式并重定向到自己。

为了避免这种多重重定向行为,您需要修复模式,使其与目标路径不匹配。只需在末尾添加regex end of string字符$,这样它只能匹配特定的uri /your-roof-as-a-selling-tool而不是...tool.html

代码语言:javascript
运行
复制
RedirectMatch 301 ^/your-roof-as-a-selling-tool$ http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47893482

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档