2

So I recently, built and LAMP server and installed wordpress on it. I connected it to the web via a reverse ssh tunnel using serveo.net. I decided to add ssl and the rest of the website seem to work fine, but wordpress keeps breaking when I try to use ssl. I went to the general settings and changed the urls to http instead of https, but when I load the pages, in the source code the css and js urls are using http instead of https, so they won't load. Then wp-admin part won't even load. How do I fix this? I've looked at quite a few posts about people having similar problems, but none of them helped.

2
  • I am very much new to wordpress development. I was about to add ssl ceritificate and for that went to General settings and add the https and removed http and saved it. After that i am not even able to login into wordpress admin. Please help me out ASAP Sep 1, 2020 at 1:43
  • @ashutoshbatta If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – bueltge
    Sep 1, 2020 at 8:13

4 Answers 4

1

Check two things:

  • in the wp-options table, the site URLs (in two places) should be the full URL, as in https://www.example.com .
  • check the site's htaccess file for proper rewrite of http to https.

For a htaccess rule, this one works in most case:

RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Then look at your theme files to ensure that any references to CSS/JS include the https protocol, not http. Most well-written themes will use relative rather than absolute references to files to include.

It's also possible a plugin might be specifying http rather than https.

Use the Network tab in Developer Tools (usually F12 in your browser) to look at each request to see where it is coming from. If the request is to a plugin folder, then check the code in there.

7
  • I'm using the default theme. twentynieteen,I'm using the default theme. twentynieteen. The database entries are correct, but the head section has stuff like <link rel='stylesheet' id='wp-block-library-css' href='jtjumper.serveo.net/wp/wp-includes/css/dist/block-library/…' type='text/css' media='all' /> <link rel='stylesheet' id='wp-block-library-theme-css' href='jtjumper.serveo.net/wp/wp-includes/css/dist/block-library/…' type='text/css' media='all' /> Feb 3, 2019 at 23:29
  • If I look at the page source on my test (hosted) site with the 2019 theme, the href for those statements includes the https: protocol. And I have the htaccess shown in my answer. And my wp-options table contains example.com , not just www.example.com . Perhaps yours is not set up that way? Feb 3, 2019 at 23:39
  • There's not enough space in the comments for the source but this is the link for the page jtjumper.serveo.net/wp my wp-options table has both, which are both https Feb 4, 2019 at 0:06
  • 1
    Disable all your plugins (especially really simple ssl). Then set your htaccess as shown. Then run a search/replace plugin (I like "Better Search and Replace") and search for yourdomain.com and replace it with yourdomain.com . Feb 4, 2019 at 1:51
  • 1
    The search-replace string mentioned in the comment above should say: search for http://yourdomain.com and replace it with https://yourdomain.com - because of formatting, it id not show correctly in the comment. Mar 1, 2020 at 23:09
1

Had the similar issue.

This answer solves most of the issues and I'm hoping you've gone through it.

The reason, I found, for HTTPS (SSL) not working on my Wordpress even after changing
1. Virtual Host File aka <web_directory>.conf file inside /ect/apache2/sites-available
2. wp-config file inside /var/www/<web_directory>/
3. [For AWS EC2 Users] Adding a load balancer with a SSL certificate for HTTPS connections

If after doing all this, you can view your website w/o CSS and JS working, then,

Last step

  1. Inside your Wordpress Dashboard, go to Settings>General

    Under, Wordpress Address (URL) add, https://<yourdomain>.com
    Under, Site Address (URL) add, https://<yourdomain>.com

I found that, when only Site Address (URL) has been activated with the website URL, Wordpress Themes automatically direct towards, the css files with HTTPS aka, https://<WordPressAddress>/css/index.css.

Only your domain has SSL access hence, adding your domain name at Wordpress Address (URL) solved the problems for me.

0

Add this code to wp-config.php in your wordpress root folder.
Also, in General Settings on the Admin Panel, change http to https for your siteurl an home.

define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
   $_SERVER['HTTPS']='on';
1
  • Why? What does it do?
    – Johan
    Sep 17, 2021 at 22:57
0

I had the same issue when I hosted my site on Azure webapp service Linux.

Try this plugin. take care when it active it works. https://wordpress.org/plugins/jsm-force-ssl/

This plugin uses native WordPress filters, instead of PHP’s output buffer, for maximum reliability, performance and caching compatibility (this plugin does not affect caching performance), along with 301 permanent redirects for best SEO (301 redirects are considered best for SEO when moving from HTTP to HTTPS).

Honors proxy / load-balancing variables for large hosting environments:

HTTP_X_FORWARDED_PROTO HTTP_X_FORWARDED_SSL Requirements:

Your web server must be configured with an SSL certificate and able to handle HTTPS request. 😉

Simply activate the plugin and you’re done:

There are no plugin settings to adjust, and no changes are made to your WordPress configuration — simply activate or deactivate the plugin to enable / disable the filters and dynamic redirects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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