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

I wanted to redirect our website to i.e. two redirects as below,
1. to [ non-www to www ]
2. or to [ from root to subfolder of root ]

Here is what .htaccess solved the problem,

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/fconn/$1 [R=301,L]

RewriteEngine On
RewriteRule ^$ /fconn [L]

The first RewriteEngine does is do 301 redirect from to
and second RewriteEngine does is redirect to

How to verify your websites current redirects,
Just type your domain name in and click Trace, or you can also use


For more help refer below URLs :

You can also refer to good information at


Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply