Select Page
How to Redirect all HTTP requests to HTTPS with htaccess

How to Redirect all HTTP requests to HTTPS with htaccess

Access your website via FTP or via your server’s File Manager and search at the root of your WordPress instalation for the .htaccess file. Here you have 3 solutions to solve the same question:

How to redirect all HTTP request to HTTPS.

Before you edit the .htaccess file, I recommend to make a backup to be able to revert your changes (in case something goes wrong).

So here you go, copy and paste the code below in your .htaccess file, save it, and re-upload it.

Solution 1

1
2
3
RewriteEngine On<br />
RewriteCond %{HTTPS} off<br />
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

These lines of code will direct all HTTP requests to https://www.example.com as well as redirect https://example.com to https://www.example.com.

Solution 2

1
2
3
4
5
RewriteEngine On<br />
RewriteCond %{HTTPS} off<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]<br />
RewriteCond %{http_host} ^example.com [NC]<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

Solution 3

1
2
3
4
5
6
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]<br />
RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR]<br />
RewriteCond %{HTTPS_HOST} ^domain.com$<br />
RewriteRule ^(.*)$ "https\:\/\/www\.domain\.com\/$1" [R=301,L]

Leave a comment with what worked for you. Go ahead and share if you have a different aproach.

How to display category description only on the first category page

How to display category description only on the first category page

If you have multiple categories that are paged on your blog, you may want to show the Category Description only on the first category page.

You may wonder how can I achive this.

It’s not that hard to do it as long as you follow the steps I provide.

  1. Connect to your FTP account and search inside your theme folder for the file archive.php. If it’s a premium theme, you should have one in you main theme folder or mabe other subfolder.
  2. Once you’ve identified the file, go ahead and download (to have a backup copy might be a good idea) and then open it up for editing.
  3. Now you’ve got to identify something similar to the code below and replace it with this one.
1
2
3
4
5
6
7
8
9
10
&lt;?php
if (is_category()) {
  $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
  if ($page == 1) {
    echo category_description();
//you don't need to include the category id on the actual
// category page - wordpress figures it out.
  }
}
?&gt;

And that’s it, pretty simple eh?

If you found this helpful please leave a comment and subscribe to my newsletter for all my latest content.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close