Use SSL in wordpress site - php

I want to go from HTTP to HTTPS on my wordpress site. So far, I have done the following:
Changed the siteurl and home addresses to https://www.example.com
In wp-config.php file added
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true); // I read this was deprecated, but I was desperate
/* That's all, stop editing! Happy blogging. */
In .htaccess I have:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
So now I face two problems:
1. css styles do not load
2. I cannot access wp-admin panel and I have error 401 The page isn’t redirecting properly
I`ve tried a lot of things and finally I really need your help, thanks!!!
EDIT!!!!
I removed the lines
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
and now it finds its way to the admin panel, but still the style files are not loaded.

Just use a Wordpress Plugin, it will save you time.
I use personally this one:
https://wordpress.org/plugins/wp-force-ssl/

Related

Wordpress has a nasty redirect not allowing ssl

I am encountering a problem with my wordpress page. I am using the sporty theme and have setup the page. Now I would like to activate SSL.
What have I done:
I changed
siteurl and home in the wp-options table
I used the DB Migrate plugin to modify all links.
I set up my htaccess file like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I am still stuck with a redirect to the base url which start with http. Even if I remove the htaccess this happens, so i doubt the htaccess is the problem.
I also tried adding
define('WP_HOME','https://tc-eislingen.de');
define('WP_SITEURL','https://tc-eislingen.de');
to the wp-config.php but the nasty redirect to http stays.
Is there a redirect in the template I am missing?
Update
Why the downvote? I followed all the rules? Is there anything wrong why my quesiton?
you shouldn't be changing .htaccess file code for it. Just change the urls in database and install
Really Simple SSL
and activate necessary settings in it. You must change http: url you placed manually into https though.

SSL only working on half of site

I have an SSL through Cloudflare and it only works on my main site, and not the wordpress part.
regular site:
http://championsdrivingschools.com
wordpress
http://championsdrivingschools.com/checkout/
If I do force SSL on the site it makes the wordpress look all it style and everything and it looks just like text
If you have added static URL in the pages without https then Url will not show green sign in the browser. please check static URL of any static assets and set below setting to make all pages with https.
Step 1: In your WordPress administrator dashboard, go to Settings -> General and change both URLs to have https:// rather than http://.
Step 2: These site asset files can easily be corrected by fixing the rewrite rules in your .htaccess file found at the root of your WordPress application.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
To get started, head to WooCommerce > Settings.

'Fetch as Google' in Webmaster tool says 'Redirected'

Google webmaster tool shows me this for my website. https://ibb.co/cnCOfk
This is a WP website, and my guess is it's because the redirection from non-www to www is not happening. Google fetches with www and then my website gets redirect too non-www domain. How do I fix this problem?
I found online that I can solve this with .htaccess. Now, I added last 2 lines (above IfModle ends). Currently, my .htaccess looks like this.
# 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]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END WordPress
Once I add this, website goes in infinite loop of "www.domainname.co" to "domainname.co" to "www.domainname.co" and so on.
How do I solve this problem? Thank you in advance.
It would seem this redirect is occurring within WordPress itself - that is where you need to fix this. You can then repeat the same redirect in .htaccess if you wish, as that would be more efficient.
But if you do the opposite redirect in .htaccess then you'll naturally get a redirect loop.
EDIT: And if you implement this redirect in .htaccess, it should go before the WordPress front controller.

CSS, JS and Images Links missing when using HTTPS

I have a serious problem with the links when using https. My knowledge with using https is poor. Although following are the processes that i've done so far.
Scenario:
I have a site that uses HTTPS. ( Certified )
I need only one CheckOut page to load in https where the checkout page is related to sub-domain. ex. member.mydomain.com
Site is in WordPress
Not using WooCommerce !!
Results:
Using htaccess i managed to redirect that certain page ie. Checkout page in https and it works.
ex. https://member.mydomain.com/checkout
However, The Problem:
The problem is that all links are dead links in the checkout page due to which it messes up the whole site. The CSS, JS files all are being loaded in https.
What i have tried so far !!
I tried updating the general settings url to https. So, it works but the same issue to all pages. All the links are broken.
Followed the instructions on this post https://wordpress.stackexchange.com/questions/75921/ssl-breaks-wordpress-css
Also, in this https://managewp.com/wordpress-ssl-settings-and-how-to-resolve-mixed-content-warnings
But the above did not seem to do the trick. I still have the broken links. What am i missing here? Please suggest.
Thank you
Found the solution finally.. Tried modifying the htaccess file again.
Following is what i added in my htaccess in order to fix the problem. It might be useful to someone in the future.
<IfModule mod_rewrite.c>
#-------------------SUB.DOMAIN.COM---------------------
RewriteCond %{HTTP_HOST} ^subdomain.domain.com
RewriteCond %{DOCUMENT_ROOT}/members%{REQUEST_URI} -f
RewriteRule . %{DOCUMENT_ROOT}/members%{REQUEST_URI} [L]
RewriteCond %{HTTP_HOST} ^ subdomain.domain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . subdirectory/index.php [L]
#-----------------SUB.DOMAIN.COM---------------------
</IfModule>
# 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]
</IfModule>
# END WordPress
This solved the subdomain issue and the 500 error requests as well as the broken links problem.

Openshift redirects wp-admin to https

In general option in wordpress, I have changed the wordpress directory to be on http://mywebsite.com but wordpress dashboard is still in htpps causing mixed content warning and images in dashboard are not displayed even after disabling mixed content filter on firefox.
I this is my .htaccess file
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
What is the possible solution to overcome this problem.
There is a setting in your wp-config.php file that directs all admin traffic over https. You would need to disable that option for your admin panel to work correctly.
FORCE_SSL_ADMIN needs to be false:
define('FORCE_SSL_ADMIN', false);
solves the issue. See relevant WordPress Codex pages:
http://codex.wordpress.org/Administration_Over_SSL
http://codex.wordpress.org/Function_Reference/force_ssl_admin

Categories