【问题标题】:htaccess Redirect Loop only on Home Pagehtaccess 重定向循环仅在主页上
【发布时间】:2023-03-19 20:41:01
【问题描述】:

今天早上我突然在访问我网站的主页时遇到了问题。 我没有做任何更改,所以我不确定问题是什么。我猜这与我的 .htaccess 文件有关。

我网站的所有其他页面,我都可以毫无问题地访问。

下面是我的 htaccess 文件。任何帮助,将不胜感激。提前致谢。

Options -Indexes
Options +FollowSymLinks

RewriteEngine   on
RewriteRule ^hats-n-caps/(.*)$ http://www.domain-domain.com/apparel/hats-n-caps/$1 [R=301,L]
RewriteRule ^electronics/laser-pointers/(.*)$ http://www.domain-domain.com/desktop-office/laser-pointers/$1 [R=301,L]
#RewriteCond %{HTTP_HOST} !^www.domain-domain.com$ [NC]
#RewriteRule ^(.*)$ http://www.domain-domain.com/$1 [L,R=301]

RewriteCond %{REQUEST_URI}  (^(.*)/site-map)
RewriteRule ^site-map$ /inc/pages/site-map.php [L]
RewriteCond %{REQUEST_URI}  (^(.*)/site-map/products-([0-9]+))
RewriteRule ^site-map/products-([0-9]+)$ /inc/pages/site-map.php?type=product&page=$1 [L]
RewriteCond %{REQUEST_URI}  (^(.*)/site-map/catalogs-([0-9]+))
RewriteRule ^site-map/catalogs-([0-9]+)$ /inc/pages/site-map.php?type=catalog&page=$1 [L]
RewriteCond %{REQUEST_URI}  (^(.*)/site-map/pages-([0-9]+))
RewriteRule ^site-map/pages-([0-9]+)$ /inc/pages/site-map.php?type=pages&page=$1 [L]

RewriteCond %{REQUEST_URI}  (^(.*)-p-(.*).html*)
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}[L]
RewriteCond %{REQUEST_URI}  (^(.*)-c-(.*).html*)
RewriteRule ^(.*)-c-(.*).html$ product_info.php?catalog_id=$2&%{QUERY_STRING}[L]
RewriteCond %{REQUEST_URI}  !(^(.*)-c-(.*).html*|^(.*)-p-(.*).html*|^/index.php|^/sitemap.xml.*|^/info.php.*|^/google_base_feed.xml.*|^/BingSiteAuth.xml.*|^/test.html.*|^/test.*|^/ajaxplorer.*|/livechat.*|^/phpmyadmin.*|^/ControlPanel.*|^/actikare.*|^/amwater.*|^/phi.*|^/sas.*|^/blog.*|^/cfscg.*|^/chase.*|^/cleaver.*|^/clubz.*|^/medicone.*|^/net2ftp.*|^/college-net.*|^/ducks.*|^/fast-teks.*|^/gatesgroup.*|^/guesthouse.*|^/neighborcare.*|^/pdf.*|^/reedrill.*|^/survey.*|^/temp.*|^/templates.*|^/tidewater.*|^/tuthill.*|^/uploads.*|^/upload.*|^/_include.*|^/product_info.*|^/server_request.*|^/server_request_products.*|^/admin.*|^/img/.*|^/images/.*|^/spaw2?|^/static/.*|^/tmp/|^/_include/|^/robots.txt|^/LiveSearchSiteAuth.xml|^/favicon.ico|/SiteReturn/.*|^/inc/pages/site-map.php(.*)|^/carousel_products.php)
RewriteRule (.*)$   /index.php [L]
RewriteCond %{HTTP_HOST} ^domain-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain-domain.com$
RewriteRule ^/?$ "\/" [R=301,L]


RewriteCond %{HTTP_HOST} ^domaindomain\.co$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domaindomain\.co$
RewriteRule ^/?$ "\/" [R=301,L]

【问题讨论】:

    标签: apache .htaccess redirect infinite-loop pydio


    【解决方案1】:

    这一行:

    RewriteRule ^/?$ "\/" [R=301,L]
    

    是导致您的重定向循环的原因。摆脱整个规则:

    # RewriteCond %{HTTP_HOST} ^domaindomain\.co$ [OR]
    # RewriteCond %{HTTP_HOST} ^www\.domaindomain\.co$
    # RewriteRule ^/?$ "\/" [R=301,L]
    

    它本质上将请求重定向到根/ 到它自己。

    【讨论】:

    • @Robert 你清除浏览器缓存了吗? 301 重定向是永久性的,浏览器会一直缓存它。
    • @Robert 你有两次这些规则,顺便说一句,你把它们都删除了吗?
    • 是的,我都删除了。我拥有它们两次,因为我拥有 domaindomain.com 和 domain-domain.com,所以它们并不完全相同。但我确实尝试将它们都删除。奇怪的是,我没有对网站进行任何更改。这只是今天早上突然发生的事情。我很确定这可能不仅仅是一个 htacess 问题。
    • 暂时解决了。谢谢你的帮助。我从一年前恢复了以前版本的 htaccess 文件。我得看看差异是什么。
    猜你喜欢
    • 2016-03-27
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 2012-10-20
    相关资源
    最近更新 更多