Solved

Forcing single permalink wordpress page into SSL

Posted on 2015-02-06
9
106 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 12

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 12

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 12

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Forward apache log to Syslog-NG 7 71
WordPress AWS: site goes down 2 78
WP WooCom Prob 7 25
Word files to Wordpress Posts 2 23
What's this? As a volunteer Page Editor for Experts-Exchange.com, I have noticed that many authors also have blogs, and pull articles from their blogs to post at Experts-Exchange. I appreciate each author sharing their blog content with our site …
WordPress can be pretty daunting, especially for a beginner, so I thought it might be a good idea to write an article to show how easy it is to get started in WordPress and to design a custom theme.  The first step is to check with your hosting comp…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

707 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

12 Experts available now in Live!

Get 1:1 Help Now