有人可以告诉我如何将.htaccess
文件修改为不重定向.txt
文件。
.htaccess
文件会将所有内容从http
重定向到https
,但我想从重定向中排除所有.txt
个文件。
这是我.htaccess
文件的当前内容:
# BEGIN Really_Simple_SSL_HSTS
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" env=HTTPS
Header always set Cache-Control "no-store, no-cache, must-revalidate"
</IfModule>
# END Really_Simple_SSL_HSTS
# BEGIN rlrssslReallySimpleSSL rsssl_version[2.5.20]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
答案 0 :(得分:1)
尝试在重写中添加另一个条件:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^.*\.txt$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>