停止在htaccess中重定向的某些文件

时间:2017-08-10 10:45:32

标签: apache .htaccess redirect mod-rewrite

有人可以告诉我如何将.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

1 个答案:

答案 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>