简体   繁体   中英

301 redirect all assets from http to https

I've searched and tried but I can't seem to find an answer on how to 301 redirect all assets when moving my http site to full https.

I'm looking for a way to either use .htaccess or httpd.conf to 301 redirect all assets (images, pdf, videos, js, css, .txt, etc) from http to https.

The full structure of both http and https remain the same.

I would appreciate any guidance on this topic.

Thanks William

# Checking if HTTPS is enabled for current page   
RewriteCond %{HTTPS} !=on 
# Redirecting any non-HTTPS document by this URL to HTTPS URL
RewriteRule (.*)\.(?:jpe?g|gif|bmp|png|tiff|css|js|pdf))$  https://%{SERVER_NAME}/$1.$2 [R=301,L]

Taken from here: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM