• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 126
  • Last Modified:

Forcing single permalink wordpress page into SSL

I am trying to force http://www.mydomain.com/page to https://www.mydomain.com/page into ssl.  This is only a single permalink wordpress page.  In my .htaccess I have this  but it doesn't seem to work.  I am using the latest version of Wordpress

#Force secure Page/post
<ifmodule mod_rewrite.c>
RewriteEngine on
#If current port is 80 (http)
RewriteCond %{SERVER_PORT} ^80$
#Then rewrite to HTTPS
#replace URI after the ^ with your wordpress permalink
RewriteCond %{REQUEST_URI} ^/page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? https://%{HTTP_HOST}%{REQUEST_URI} [L,S=1,R=301]
</ifmodule>

#Escape secure form page/post
<ifmodule mod_rewrite.c>
#if current port is 443 (https)
RewriteCond %{SERVER_PORT} ^443$
#and you’re NOT on the page you specified above rewrite to http
#Replace URI after the ^ with the same permalink as above
RewriteCond %{REQUEST_URI} !^/page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</ifmodule>

#start wordpress
<ifmodule mod_rewrite.c>
RewriteEngine On
#RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</ifmodule>

Open in new window

0
stargateatlantis
Asked:
stargateatlantis
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
Edwin HofferTechnical ExpertCommented:
Hello,

Try the below code in your .htaccess file:

Options +FollowSymLinks
RewriteEngine on

# redirect for http /buy page
RewriteCond %{SERVER_PORT} =80
RewriteRule ^page/?$ https://mydomain.com/page [R=301,QSA,L,NE]

Hope that helps you

Thanks
Edwin
0
 
stargateatlantisAuthor Commented:
I don't think that will work it probably has to do something with wordpresss.  I tried it in my code but it says page not found.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Options +FollowSymLinks
# redirect for http /buy page
RewriteCond %{SERVER_PORT} =80
RewriteRule ^page/?$ https://mydomain.com/shop [R=301,QSA,L,NE]

</IfModule>

# END WordPress

Open in new window

0
 
Edwin HofferTechnical ExpertCommented:
Change "page/" to your page name and mydomain.com/shop to your domain
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
stargateatlantisAuthor Commented:
I tried that but it doesn't work

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Options +FollowSymLinks
# redirect for http /buy page
RewriteCond %{SERVER_PORT} =80
RewriteRule ^auth/?$ https://www.mydomain.com/auth [R=301,QSA,L,NE]

</IfModule>

# END WordPress

Open in new window

0
 
Jason C. LevineNo oneCommented:
Instead of screwing around with .htaccess, try this plugin:

https://wordpress.org/plugins/wordpress-https/

Just easier...
0
 
stargateatlantisAuthor Commented:
That plugin is out of date and hasn't been updated in while.
0
 
Jason C. LevineNo oneCommented:
Nope.  It hasn't been updated because the functionality it provides doesn't need an update. We use it on all our sites and it's safe and secure.
0
 
Edwin HofferTechnical ExpertCommented:
Try this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# force https for all URLs in /auth
RewriteCond %{HTTPS} =off
RewriteRule ^auth https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

</IfModule>

# END WordPress

Open in new window

0
 
Lucas BishopClick TrackerCommented:
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} page
RewriteRule ^(.*)$ https://www.mydomain.com/page/$1 [R,L]

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now