gooブログはじめました!

写真付きで日記や趣味を書くならgooブログ

htaccess forced HTTPS on your website

2021-06-30 11:24:42 | Wordpress

 

Using .htaccess file to force HTTPS links in WordPresshttps

Fix .htaccess to process website assets such as CSS and JavaScript under HTTPS

This is the thing that got me when I was making the full transition to HTTPS for my blog.  After changing the site name, all my CSS and JavaScript assets were still coming in with the HTTP URL path rather than HTTPS.  This caused my site to appear broken in pretty much every browser.

These site asset files can easily be corrected by fixing the rewrite rules in your .htaccess file found at the root of your WordPress application.

 

1
2
3
4
5
6
7
8
9
10
11
12
# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Notice the highlighted lines in the above code.  We’re saying that if the current port isn’t 443, then rewrite the URL to use HTTPS with a 301 redirect.  The rest of the above code should already exist in your WordPress .htaccess file. Usually, it will be found at the bottom of the file.

 

https wordpress htaccess

 

Well done and thank you to:

https://www.thepolyglotdeveloper.com/2014/12/force-https-pages-wordpress-site/

Even easier just past this at the very top first line of your .htaccess file:

<iframe id="aswift_2" src="https://googleads.g.doubleclick.net/pagead/ads?us_privacy=1---&client=ca-pub-6102346210774523&output=html&h=280&adk=3591698004&adf=2211953984&pi=t.aa~a.1305852435~i.25~rp.4&w=930&fwrn=4&fwrnh=100&lmt=1625019964&num_ads=1&rafmt=1&armr=3&sem=mc&pwprc=2692842441&tp=site_kit&psa=1&ad_type=text_image&format=930x280&url=https%3A%2F%2Fwww.wanttono.com%2Fwordpress%2Fhtaccess-https%2F&flash=0&fwr=0&pra=3&rh=200&rw=930&rpe=1&resp_fmts=3&wgl=1&fa=27&uach=WyJXaW5kb3dzIiwiMTAuMCIsIng4NiIsIiIsIjkxLjAuNDQ3Mi4xMjQiLFtdLG51bGwsbnVsbCxudWxsXQ..&tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9hZHNlcnZpY2UuZ29vZ2xlLmNvbSIsInN0YXRlIjozfSx7Imlzc3Vlck9yaWdpbiI6Imh0dHBzOi8vYXR0ZXN0YXRpb24uYW5kcm9pZC5jb20iLCJzdGF0ZSI6N31d&dt=1625019963231&bpp=6&bdt=1331&idt=7&shv=r20210624&cbv=%2Fr20190131&ptt=9&saldr=aa&abxe=1&cookie=ID%3D7805708242c5c9fb-222f42de27c90016%3AT%3D1624524776%3ART%3D1624524776%3AS%3DALNI_MZdAfTAbr9hr589ZAqGHEM3bFMk5Q&prev_fmts=0x0%2C1200x280&nras=3&correlator=3863089554386&frm=20&pv=1&ga_vid=215314185.1624524774&ga_sid=1625019963&ga_hid=60336839&ga_fc=0&u_tz=300&u_his=1&u_java=0&u_h=864&u_w=1536&u_ah=824&u_aw=1536&u_cd=24&u_nplug=3&u_nmime=4&adx=379&ady=3093&biw=1688&bih=802&scr_x=0&scr_y=0&eid=182982100%2C182982300%2C21067496%2C31061662&oid=3&pvsid=2512035661261098&pem=517&ref=https%3A%2F%2Fwww.wanttono.com%2Fwp-admin%2Fedit.php&eae=0&fc=1408&brdim=0%2C0%2C0%2C0%2C1536%2C0%2C1536%2C824%2C1707%2C802&vis=1&rsz=%7C%7Cs%7C&abl=NS&cms=2&fu=128&bc=31&ifi=3&uci=a!3&btvi=1&fsb=1&xpc=kGGpiaAqIU&p=https%3A//www.wanttono.com&dtd=976" name="aswift_2" width="930" height="0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" allowfullscreen="true" data-google-container-id="a!3" data-google-query-id="CIvj3I2nvvECFWYo0wodcsUMAw" data-load-complete="true"></iframe>

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

 

https://www.wanttono.com/wordpress/htaccess-https

 



最新の画像もっと見る

コメントを投稿

ブログ作成者から承認されるまでコメントは反映されません。