Below snippet shows how to redirect a site from non-www to www (or viceversa) and from HTTP to HTTPS. To be more clear, the configuration will redirect the following host names:
http://onlinenote.in
https://onlinenote.in
to
https://www.onlinenote.in
I’ll also show a small change to redirect the www to the non-www version, if you prefer the non-www.
To configure the redirects, add the following redirect rule either to the Apache config file if you have access to it, or to the .htaccess
in the root of your site:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
If instead of www.onlinenote.in
you want the default URL to be onlinenote.in
, then simply change the third and the fifth lines:
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]
To remove the .html extension from your urls, you can use the following code in…
If you get 404 page not found error after installation. In this case your server…
Below snippet shows how to redirect a site from non-www to www [crayon-67b07832bc249407904768/] or [crayon-67b07832bc24e628633241/]…
Below shows common redirects using htaccess file. [crayon-67b07832bc456142594932/] The CI .htaccess shouldn't be in the…