I used Sakura rental server, introduced Wordpress, and applied my own SSL.
I wanted to redirect only the contact page to https, but I couldn't solve it myself.
I typed the following in .htaccess and uploaded it to the root folder.
Both HTTPS and HTTP will fly to the top page.
RewriteEngine On
RewriteBase/
# When accessed via HTTP,
RewriteCond%{HTTP:X-Sakura-Forwarded-For}^$
# Skip only this page to HTTPS
RewriteCond%{REQUEST_URI}^/contact/.*$
RewriteRule^.*$https://www.example.com% {REQUEST_URI} [R,L]
If you enter so far, contact redirects to https.
If you add the code below, contact will redirect you to the front page.
# When accessed by HTTPS, click
RewriteCond%{HTTP:X-Sakura-Forwarded-For}!^$
# Skip to HTTPS other than this page
RewriteCond%{REQUEST_URI}!^/contact/.*$
RewriteRule^.*$http://www.example.com% {REQUEST_URI} [R,L]
# original wordpress code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule^index\.php$ - [L]
US>RewriteCon%{REQUEST_FILENAME}!-f
RewriteCon%{REQUEST_FILENAME}!-d
RewriteRule./index.php [L]
</IfModule>
# END WordPress
Thank you for your cooperation.
wordpress .htaccess https
I don't know if the code is correct, but I solved myself while I was searching.
There may be a smarter way to do this, but here's the code for the desired behavior:
RewriteEngine On
# If you access the contact page via http://
RewriteCond%{REQUEST_URI}^/contact/$
RewriteCond%{HTTP:X-Sakura-Forwarded-For}^$
RewriteRule^(.*)$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
# If you access anything other than the top page via https://
RewriteCond%{REQUEST_URI}!^/contact/$
RewriteCond%{HTTP:X-Sakura-Forwarded-For}!^$
RewriteRule^(.*)/$http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# If you access the front page via https://
RewriteCond%{HTTP:X-Sakura-Forwarded-For}!^$
RewriteRule^$ http://www.example.com/ [L,R=301]
333 Understanding Multiple Dictionary Comparisons in Python
372 Update Flask User Information
342 Memory layouts learned in theory don't work out as expected when actually printed as addresses.
346 Who developed the "avformat-59.dll" that comes with FFmpeg?
367 To Limit Column Values to Strings in a String List Using sqlalchemy
© 2023 OneMinuteCode. All rights reserved.