etrader Posted July 20, 2009 Share Posted July 20, 2009 All instructions on the web are about redirecting domain.com to www.domain.com via .htaccess. How is the htaccess command to permanently redirect "www.domain.com to domain.com" or "www.domain.com to an external domain" ? Quote Link to comment https://forums.phpfreaks.com/topic/166597-withwithout-www/ Share on other sites More sharing options...
dreamwest Posted July 20, 2009 Share Posted July 20, 2009 RewriteCond %{HTTP_HOST} ^site.com [NC] RewriteRule (.*)$ http://www.site.com/$1 [L,R=301] Redirects http://site.com to http://www.site.com Quote Link to comment https://forums.phpfreaks.com/topic/166597-withwithout-www/#findComment-878495 Share on other sites More sharing options...
etrader Posted July 20, 2009 Author Share Posted July 20, 2009 This is my problem; all instructions show this, but I want to redirect www.domain.com to domain.com Quote Link to comment https://forums.phpfreaks.com/topic/166597-withwithout-www/#findComment-878623 Share on other sites More sharing options...
sKunKbad Posted July 21, 2009 Share Posted July 21, 2009 Simple RewriteCond %{HTTP_HOST} ^www.site.com [NC] RewriteRule (.*)$ http://site.com/$1 [L,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/166597-withwithout-www/#findComment-879877 Share on other sites More sharing options...
etrader Posted July 25, 2009 Author Share Posted July 25, 2009 But still I had some problem, since I had some other rewrites on my .htaccess could you please tell me the whole .htaccess for redirecting both www.domain.com and domain.com to an external domain! Quote Link to comment https://forums.phpfreaks.com/topic/166597-withwithout-www/#findComment-882877 Share on other sites More sharing options...
dreamwest Posted July 25, 2009 Share Posted July 25, 2009 # permanently redirect from www domain to non-www domain RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC] RewriteRule ^(.*)$ http://domain.tld/$1 [R=301,L] OR # redirect from old domain to new domain RewriteEngine On RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L] OR # redirect an entire site via permanent redirect Redirect permanent / http://www.domain.com/ Quote Link to comment https://forums.phpfreaks.com/topic/166597-withwithout-www/#findComment-882898 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.