Redirect all non www to www Except Some Path

Redirect all non www to www Except Some Path

Redirect using .htaccess file

In public_html folder of your domain create a .htaccess file with this content

RewriteEngine on
RewriteRule !^forum($|/)  http://www.amritdevkota.com.np%{REQUEST_URI} [L,R=301]

This will Redirect all non www to www version of website except a path /forum or /forum/

It is Usefull For those Blogger Users who is hosting their own Domain in blogger, Who want to make some own coding pages on their website. I was seeking this solution since long time by time I get This Which Helps me The Best way.

For Redirecting all non www to www except Some Path Rewrite The .htaccess file as

RewriteEngine on
RewriteRule !^(forum|test)($|/)  http://www.amritdevkota.com.np%{REQUEST_URI} [L,R=301]

Just Add (and add any path you want not to redirect and sepa|rate with |)

This Domain was hosted on blogger and i had Created a simple Forum in Php i want insert it on my own Domain but We cant upload files in Blogger. So I need to redirect amritdevkota.com.np to www.amritdevkota.com.np But amritdevkota.com.np/forum as Usual.

There is another way Like Creating redirect in index.php  But it does not help as i Had not Created any 404 error page and many more.

If You Just Want to Redirect Non www to www (Not Related with Blogger)
Just Create a .htaccess file with following Content:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^amritdevkota.com.np [NC]
RewriteRule ^(.*)$ http://www.amritdevkota.com.np/$1 [L,R=301,NC]

This Will Redirect all Request For amritdevkota.com.np to www.amritdevkota.com.np
It was as we visit amritdevkota.com.np/asdfasdf it is Redirected to www.amritdevkota.com.np/asdfasdf

If you Get any 500 Internal Error Check corectly The Code is Fine.