Fat Heads tips and techniques logo

Duplicate HTTP and HTTPS in Drupal 7

Sean avatar
by Sean
Digital Director
Posted 09 Nov 2018

Using your .htaccess to remove duplicate content isues with HTTP and HTTPS Drupal 7 links is easily fixed with this technique.

If you’re running a Drupal 7 website with an SSL certificate, you might encounter an issue where your site is accessible via both HTTP and HTTPS URLs. This can create duplicate content problems, negatively impacting your site’s search engine rankings. To prevent this, you need to redirect all HTTP traffic to HTTPS using a simple .htaccess update.

Why Use HTTPS for Your Website?

HTTPS (Hypertext Transfer Protocol Secure) is essential for safeguarding sensitive data transmitted between a user’s browser and your website. Without HTTPS, information can be intercepted, posing security risks. HTTPS is crucial when handling:

  • Credit card information
  • Session cookies (e.g., PHP session cookies)
  • Usernames and passwords
  • Personally identifiable information (PII) like names, addresses, emails, passport numbers, or national insurance details
  • Confidential content

Implementing HTTPS protects user data, builds trust, and even improves SEO rankings, as search engines favor secure sites. To enable HTTPS, you’ll need to install an SSL certificate on your server.

What’s the Difference Between HTTP and HTTPS?

Most visitors won’t notice significant differences between HTTP and HTTPS sites. The key indicators are the URL starting with https:// instead of http:// and the appearance of a padlock icon in the browser’s address bar, signaling a secure connection.

How to Redirect HTTP to HTTPS in Drupal 7

To ensure all traffic is securely redirected to HTTPS, add the following code to your site’s .htaccess file:

# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code checks if HTTPS is off and redirects all HTTP requests to the secure HTTPS version of your site using a 301 (permanent) redirect.

Final Step: Test Your Site

After updating your .htaccess file, test your website by accessing it via http://. You should be automatically redirected to the https:// version. If everything works smoothly, your site is now more secure and SEO-friendly.

Recent articles

WordPress vs Drupal

Drupal vs. WordPress: Which Web Platform is Better for Your Website?

Drupal vs. WordPress: Compare ease of use, customization, security, scalability, and more to choose the right CMS for your website.

06 Feb 2025
Illustrated web design North East England map

Top 5 Website Projects for North East Clients

Transforming web design in Newcastle, Hartlepool and East Durham with these standout projects for educational and community organisations.

14 Jan 2025
Accessible Web Design - East Durham College

Accessible Web Design for Local Education

Learn about essential tips, legal obligations, common barriers, and tools for creating inclusive educational websites.

02 Jan 2025
J Allcocks & Sons website on iMac

Creating a web presence for J. Allcock & Sons LTD

Discover how Fat Heads designed a sleek, eco-friendly website for a 100-year-old leader in rubber recycling and sustainability.

19 Dec 2024