我的文件需要通过http访问外部源。我的整个网站都是https。如果我执行以下操作:
# Redirect all http traffic to https, only if it is pointed at specialfile.txt
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/specialfile.txt/
RewriteRule ^(.*)$ http://example.com/specialfile.txt$1 [R=301,L]
看起来这会起作用吗?当谈到Apache重写规则时,我是一个绝对的菜鸟,我会RTFM,但我很快就需要这个改变。
我还应该提到已经有了
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
在.htaccess文件中以及一些Wordpress内容。
答案 0 :(得分:0)
如果你在根文件夹.htaccess
文件中添加如下内容,它应该可以工作:
RewriteEngine on
RewriteCond %{REQUEST_URI} specialfile.txt$
RewriteRule ^(.+)$ http://example.com/$1 [R=301,L]
该指令翻译为:
specialfile.txt
https://domain.tld/
http://domain.tld/all-captured-characters