【问题标题】:Too many redirection CSS重定向 CSS 过多
【发布时间】:2021-04-16 12:39:29
【问题描述】:

我得到错误 style.css:1 GET https://www.example.com/cs_CZ net::ERR_TOO_MANY_REDIRECTS

可能与我的 htaccess 相关?

RewriteEngine On
AddDefaultCharset utf-8
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]  
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]

编辑: @RavinderSingh13 更改后,我有权限错误

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite url-rewriting


    【解决方案1】:

    按照以下方式保存您的 htaccess 文件,请确保在测试您的 URL 之前清除浏览器缓存。

    RewriteEngine On
    AddDefaultCharset utf-8
    ##Placing rules for non-https URLs here to apply https on URLs.
    ##Fixes: Added NE flag in rules here.
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
    
    ##Placing rules for non www URLs here to apply www on URLs.
    ##Fixes: Added NE flag in rules here.
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]
    
    ##Rules for files to block those urls.
    ##Fixes: Added L flag to the rules.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [F,L]
    RewriteRule ^\.htaccess/?$ - [F]
    
    ##Removed condition RewriteCond %{REQUEST_URI} ="" here as its not required.
    RewriteRule ^/?$ /public/index.php [L]
    
    ##Rules for non public uris to handle here.
    RewriteCond %{REQUEST_URI} !^/public [NC]
    RewriteRule ^(.*)/?$ /public/$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(public)/.*$ /$1/index.php [QSA,NC,L]
    

    【讨论】:

    • 好答案拉文德。我可以看到你修正了最后一条规则。它应该可以工作 +1 。
    • 谢谢@RavinderSingh13,我改变了我的答案。看来,您的版本返回错误。
    猜你喜欢
    • 2011-06-17
    • 2016-07-19
    • 1970-01-01
    • 2021-03-20
    • 2018-12-16
    • 1970-01-01
    • 2017-12-15
    • 2021-02-22
    相关资源
    最近更新 更多