How to setup 301 redirect from non-www to www and subfolder

If you want to redirect non-www URL to https://www. which improves search engine optimisation rankings, use following .htaccess rule as,

Here is what .htaccess solved the problem,

[code] RewriteEngine On RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] [/code]

How to verify your websites current redirects ?

Just type your domain name in http://redirectcheck.com/index.php and click Trace, or you can also use http://www.redirect-checker.org

For more help refer below URLs :

  • https://www.namecheap.com/support/knowledgebase/article.aspx/9410/29/how-to-setup-rules-and-redirects-in-htaccess
  • https://moz.com/learn/seo/redirection
  • https://support.google.com/webmasters/answer/93633

You can also refer to good information at https://gist.github.com/ScottPhillips/1721489


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded