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]
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
578 Understanding How to Configure Google API Key
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.