Hello friends i have some problem with 301 permanent redirect. i want to redirect my site to http://xys.com to http://www.xys.com. so i was put the code in .htaccess file but that is not working. i was write below code in .htaccess Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^xys.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^(.*) http://www.xys.com/$1 [L,R=301] and my site hosting with lunarpages and lunarpages by default mod_wirte is enable and i was put .htaccess file in that folder where index.aspx file. if i am wrong any step then please suggest me. so please friend help me. Thanks a lot in advance.
this is what i use myself RewriteEngine on rewritecond %{http_host} ^abc.com [nc] rewriterule ^(.*)$ http://www.abc.com/$1 [r=301,nc] Code (markup): however, this is for linux based hosting. if you have windows hosting, you would need some other code. google "htaccess 301 redirect" or something along the line and you will find lot of help keep in mind that after changing the code, your server might take a little time before the redirect starts working. i would say allow about 15 minutes or so before you change the code back
Ahmed's code looks right to me, so give it a try. You may like to check http://forums.digitalpoint.com/forumdisplay.php?f=18 forum too for more apache and .htaccess related content Edit - just saw your post, so you are on IIS ? I don't have much knowledge of IIS and what lunarpages is providing but you can look at these steps - In iis Admin: 1. Browse the website you want to do the redirect for. 2. In the right pane, right click on the file you want to redirect, and click "Properties" 3. Under the "File" tab, hit the radio selection "A redirection to a URL" 4. Put the target in the "Redirect to" textarea. 5. Make sure "The exact URL entered above" and "A permanent redirection for this resource" Ref - WMW
well, then you are going the wrong direction to begin with. htacess files dont work with windows and only way to do a server side redirection with windows hosting is by having access to your IIS admin panel which you dont have. you need to use javascript on each page to redirect them to new page which is pretty much the only way you can do this unless you can have your host do this for you in the admin panel. again, do a search on google for windows 301 redirct for the code as i dont use windows server so dont have the code handy @ poseidon, op is using lunarpages as a host and not hosting his site on his own IIS server so dont have access to IIS admin panel.