调试我继承的.htaccess文件

问题描述 投票:0回答:1

我从以前的Web开发人员那里继承了以下.htaccess文件。我对这里的一些规则感到困惑,并且对事物进行了无限循环。

<IfModule mod_security.c>
SecRuleRemoveByID 000014
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

# STRIP .HTML FROM DISPLAY
RewriteCond %{REQUEST_URI} !^/(dashboard|editor/.*)$
RewriteCond %{THE_REQUEST} ^(.+)\.html([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.html$ /$1 [R=301,L]

RewriteCond %{REQUEST_URI} !^/(dashboard|editor/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html

RewriteCond %{REQUEST_URI} !^/(dashboard|editor/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

我想要完成的是以下内容:

  1. 附加www。到所有传入的URL
  2. 将所有http请求重定向到https
  3. 显示所有传入的.html网址,不带.html

我们在/ dashboard和/ editor中有一个角度应用程序,我们需要确保从任何重写规则中排除这些目录。

请帮忙!

apache .htaccess mod-rewrite url-rewriting
1个回答
1
投票

打开调试通过

LogLevel alert rewrite:trace6

(在apache2.4及以上)并跟踪它。见How to debug Apache mod_rewrite

我可以想象几个坏消息,包括apache在某种反向代理后面,通过端口80与它通信,因此http-> https规则会被永远重新调用。

© www.soinside.com 2019 - 2024. All rights reserved.