Ok, so I have a wordpress site with a lot of pages and menus that I've defined in the appearance/menus section of wordpress.

One of my pages has a little payment form on, which I'd like to link to with https://blahlbah.com/thepage.. and for all the other pages I'd like them to remain as http.

Even if I set an absolute link to the https page all the other pages being relative links become https also after you visit that page.

Is there a plugin or a hack or something to just specify that one page as https?

Cheers, John.


You will need to convert the relative links to absolute links. You can do this in the wp_nav_menu_objects filter, which gets all menu items. Just edit the url property of each item.

Another option would be to extend the default Walker_Nav_Menu with one that overrides start_el(), so you can modify the passed $item there before you pass it to the parent start_el().

These are relative links you added yourself? If you add a link to a WordPress Page or Post via the menu editor it should be absolute by default.


I like Jan's first idea--filtering wp_nav_menu_options. Could be a good all-around solution, and could be quickly turned into a plugin. Maybe even add a checkbox to the edit screen saying "serve this page over SSL" or something?

In the past, I've used a hacky redirect solution with htaccess. It looks something like:

# Force a given page to https
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /your-ssl-page/$
RewriteRule ^(.*)$ https://www.example.com/your-ssl-page/ [R=301,L]

# Force everything BUT the given page to regular http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/your-ssl-page/$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

This works well (and is very easy to implement) if you're only worried about one page, but gets to be a real pain if you have a bunch of HTTPS URIs, or if you're not good at troubleshooting rewrite rules :)

  • Will this affect the sites seo ranking? since we are redirecting too much pages by this? – Binod Kalathil May 29 '14 at 15:51
  • 1
    @Binod Not sure why it would have a negative affect on SEO. I doubt that search engines track how long a particular 301 has been in place, or how often its used. But I could be wrong. – MathSmath Jun 24 '14 at 21:22

Here is some code to force SSL on non-ssl pages:

// Force SSL
if( !is_ssl() ){
    if ( 0 === strpos($_SERVER['REQUEST_URI'], 'http') ) {
    wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
} else {
    wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);

Basically, you can use this code to force ssl on your desired page(s) and do the opposite to remove ssl for all other pages. You may, in this case, want to specify the second parameter for wp_redirect to enable a 301 redirect rather than a 302. You will also want to ensure as best you can that all links point to the https version.

  • 1
    For added security, use wp_safe_redirect() instead of wp_redirect(). – Micah Wood Jun 11 '14 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.