Solved

Forcing single permalink wordpress page into SSL

Posted on 2015-02-06
9
107 Views
Last Modified: 2015-02-23
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
Comment
Question by:stargateatlantis
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:Edwin Hoffer
ID: 40593785
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
 

Author Comment

by:stargateatlantis
ID: 40593858
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
 
LVL 14

Expert Comment

by:Edwin Hoffer
ID: 40593945
Change "page/" to your page name and mydomain.com/shop to your domain
0
 

Author Comment

by:stargateatlantis
ID: 40593960
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40593971
Instead of screwing around with .htaccess, try this plugin:

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

Just easier...
0
 

Author Comment

by:stargateatlantis
ID: 40593982
That plugin is out of date and hasn't been updated in while.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40594017
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
 
LVL 14

Assisted Solution

by:Edwin Hoffer
Edwin Hoffer earned 250 total points
ID: 40594064
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
 
LVL 16

Accepted Solution

by:
Lucas Bishop earned 250 total points
ID: 40595278
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} page
RewriteRule ^(.*)$ https://www.mydomain.com/page/$1 [R,L]

Open in new window

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I want to start by talking about the use of plug-ins for WordPress. I started a web-site for a company I was working for a few years ago; I had extremely basic knowledge of HTML. I am a Graphic Designer by trade so I invited the opportunity as a cha…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now