You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

网站迁移后出现ERR_TOO_MANY_REDIRECTS循环问题求助

Why Your .htaccess Is Causing ERR_TOO_MANY_REDIRECTS

The redirect loop is definitely coming from the conflicting use of both RewriteRule and FallbackResource in your .htaccess file. Here's exactly why that happens:

  1. Your RewriteRule already handles routing to index.php:

    • The rule targets any request that isn't a directory, doesn't start with /resource, and doesn't already include index.php. It rewrites those requests internally to /index.php and stops processing further rewrite rules (thanks to the [L] flag).
  2. FallbackResource creates an unnecessary loop:

    • FallbackResource /index.php tells Apache to serve index.php whenever the requested path doesn't exist. But since your RewriteRule already does this, having both leads to redundant processing.
    • Apache runs mod_rewrite first, which rewrites the request to index.php. Then mod_dir (which handles FallbackResource) kicks in. Even though index.php exists, the internal rewrite from mod_rewrite can trigger a secondary check where mod_dir tries to apply FallbackResource again. This creates an infinite internal loop that Apache eventually cuts off by sending the ERR_TOO_MANY_REDIRECTS error to the browser.
  3. Subdirectory hosting can worsen this:

    • If your site is in a subdirectory (not the server root), the absolute path /index.php in your RewriteRule points to the root's index.php (which probably doesn't exist). Apache then uses FallbackResource to try serving your subdirectory's index.php, which starts the cycle over again.

The Fix

Remove the redundant FallbackResource line—your RewriteRule already covers the routing you need. Here's the cleaned-up .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\/resource.*$
RewriteRule ^((?!index\.php).+)$ /index.php [L]

If your site is hosted in a subdirectory, add a RewriteBase directive (replace /your-subdir/ with your actual subdirectory path) and adjust the RewriteRule target to use a relative path:

RewriteEngine on
RewriteBase /your-subdir/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\/resource.*$
RewriteRule ^((?!index\.php).+)$ index.php [L]

内容的提问来源于stack exchange,提问作者Elbarbu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 09:55:13