Redirect from http to https exploitation .htaccess go into codeigniter OR wordpress

Redirect from http to https exploitation .htaccess go into codeigniter OR wordpress

If you want to add www with every request of your site, i.e someone wants to access your site without www and you need to redirect from keephoster.com to www.keephoster.com how can you do that..?

If you have a WordPress site then definitely you have multiple options, either you can install the plugin Really Simple SSL  or you can find some other plugins which redirect your requests,  but why you need to install a plugin if you have many plugins already installed inside your project/theme.

If you’re talking regarding Codeigniter it’s straightforward to direct your request using .htaceess however before using .htaccess files in CodeIgniter OR in WordPress you have got to familiar with .htaccess file

What is SSL…?

SSL(Secure Sockets Layer) Certificates are small data files that digitally bind a cryptographic key to an organization’s details. When installed on a web server, it activates the padlock and the https protocol and allows secure connections from a web server to a browser.

What is .htaccess file..?

.htaccess is a configuration file for use on web servers running the Apache Web Server software.

Now we are going to add .htaccess file that redirects your request from http to HTTPS.

Step 1: Create .htaceess file in your root folder and copy this code in the file.

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTP_HOST} ^yourDomainName\.com$ [NC]
RewriteRule ^ https://www.yourDomainName.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ yourDomainName.com/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

If you want to redirect your request form HTTP to https without installing any plugin then just find the .htaccess file in your root directory and open it.

find RewriteEngine On and copy this code below it.

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTP_HOST} ^yourDomainName\.com$ [NC]
RewriteRule ^ https://www.yourDomainName.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ yourDomainName.com/$2 [R=301,L]

You can also install a plugin to solve your redirect issue if you are not using code.