2017-08-10 37 views
1

有人可以告訴我如何修改我的.htaccess文件以不重定向.txt文件。停止某些文件在htaccess中重定向

.htaccess文件重定向從httphttps一切,但我想從重定向排除任何.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

嘗試增加其他條件來重寫:

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteCond %{HTTPS} !=on [NC] 
    RewriteCond %{REQUEST_URI} !^.*\.txt$ 
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
</IfModule> 
+0

雖然你可能要確保網址不會結束'.txt',而不是簡單地不包含'.txt'。例如。 '!\ TXT $'。在'RewriteRule'模式中這樣做會更有效率,而不是使用額外的'RewriteCond'指令。例如。 'RewriteRule!\。txt $ https:// ....' – MrWhite