將 所有 http 轉成 https ....當不是 https 進來時 ..... Apache
RewriteEngine On
RewriteCond %{HTTPS} off
# RewriteCond %{SERVER_PORT} !=443
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
nginx ....
server {
listen 80 default_server;
listen [::]:80 default_server;
<strong>server_name example.com www.example.com;</strong>
return 301 https://<strong>$server_name</strong>$request_uri;
}
那還有其他方法嗎 ?
Apache (2.X 的要查一下 ...太舊版本沒有 )......有 sed .,....這超棒的
# In the following example, the sed filter will change the string # "monday" to "MON" and the string "sunday" to SUN in html documents # before sending to the client. <Directory "/var/www/docs/sed"> AddOutputFilter Sed html OutputSed "s/monday/MON/g" OutputSed "s/sunday/SUN/g" </Directory> # In the following example, the sed filter will change the string # "monday" to "MON" and the string "sunday" to SUN in the POST data # sent to PHP. <Directory "/var/www/docs/sed"> AddInputFilter Sed php InputSed "s/monday/MON/g" InputSed "s/sunday/SUN/g" </Directory>
還是 Apache 的 Substitute (.太舊版本沒有 ...用錢要查一下 )
<Location /> AddOutputFilterByType SUBSTITUTE text/html Substitute "s|href="http://blog.dembowski.net/|href="https://blog.dembowski.net/|" Substitute "s|href='http://blog.dembowski.net/|href='https://blog.dembowski.net/|" Substitute "s|src=' http:|src='|" Substitute "s|src="http:|src="|" </Location>
Nginx 的 Substitute
location / {
sub_filter '<a href="http://127.0.0.1:8080/' '<a href="https://$host/';
sub_filter '<img src="http://127.0.0.1:8080/' '<img src="https://$host/';
sub_filter_once on;
}
location / {
subs_filter_types text/html text/css text/xml;
subs_filter st(\d*).example.com $1.example.com ir;
subs_filter a.example.com s.example.com;
}
location / {
sub_filter_types text/html text/css text/xml;
sub_filter 'http.example.com' 'https.example.com';
}
文章標籤
全站熱搜
