The Web Blinders logo

Programming

APACHE .HTACCESS NON-WWWW TO WWW AND HTTP TO HTTPS REDIRECT FOR SUBDIRECTORIES TOO

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301] 

Copy above code to .htaccess file and place it in your server root www folder.

This code will..

  • Redirect non-www to www.
    For example: thewebblinders.in to www.thewebblinders.in(with https)
  • Redirect http to https.
    For example: http://thewebblinders.in to https://www.thewebblinders.in
  • Example for sub directories.http://thewebblinders.in/loveanalysis to https://www.thewebblinders.in/loveanalysis

ALTERNATE TITLES

Canonical issue resolve domain google seo

apache .htaccess tutorials

apache non www to www .htaccess mod_rewrite redirect

non-www to www redirect for sub directories / folders

apache http to https redirect .htaccess for sub directories / folders
mod_rewrite tutorials

httpd.conf tutorials

Need developers ?

if so, send a message.

thewebblinders@gmail.com

More Programming from our blog

SEARCH FOR ARTICLES