PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 19, 2022

[FIXED] Not Directing Http/www traffic to HTTPS

 February 19, 2022     .htaccess, codeigniter, https, mod-rewrite, routes     No comments   

Issue

so I have installed ssl certificate on my server, so if search using https://www.domain.info its secure connection. but if i search using www.domain.info or http://www.domain.info it doesnt redirect to https for a secure connection.

this is my current htaccess content


RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]


Solution

Looks like your htaccess file is not enabled mod rewrite rule at present, try un-commenting line LoadModule rewrite_module modules/mod_rewrite.so once. Plus go through article https://phoenixnap.com/kb/how-to-set-up-enable-htaccess-apache for understanding on how to enable htaccess file.

Also change your rules to following.

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]


Answered By - RavinderSingh13
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing