Initially I don’t the purpose of .htaccess and now I bought my own domain so, I realized the need of .htaccess, here I just use this .htaccess for redirect website URL www to non-www and non-www to www. Let see how the .htaccess code is works here, and how we want to use this .htaccess.
Usually our URL comes like 2my4edge.com, so we have to make our URL like, www.2my4edge.com. For that here we are going to use this .htacces file, in this file first we have to RewriteEngine On,
file allocation image sample
that's it, enjoy
Non-www to www
Usually our URL comes like 2my4edge.com, so we have to make our URL like, www.2my4edge.com. For that here we are going to use this .htacces file, in this file first we have to RewriteEngine On,
And then RewiteCondition comes like% {HTTP_HOST} and ^ symbol is for from there the url is starts, and yoursite\.com[NC].
And then, here we have to add the www. RewriteRule(.*)http://www.yoursite.com/$1[L,R=301]
.htaccess code
RewriteEngine On RewriteCond %{HTTP_HOST} ^yoursite\.com [NC] RewriteRule (.*) http://www.yoursite.com/$1 [L,R=301]
file allocation image sample
www to non-www
similar action as the above.
.htaccess code
RewriteEngine On RewriteCond %{HTTP_HOST} ^www.yoursite.com RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
that's it, enjoy
hello Arun my website developed in C#.net and Asp.net using IIS 7. Could you please guide me how to use .htaccess in .net . thanks in adavance...
ReplyDeleteWhen i check my file manager there is no .htaccess file. Then i try adding a new .htaccess file and add required code. But still its not working for me. Can you help me?
ReplyDeleteHi, there is some problem with godaddy server using this redirection.
ReplyDeletewhen redirect with domain.com to www.domain.com then page says that there is no page available for www.domain.com