I want to redirect mysite.com or http://mysite.com or www.mysite.com or any other format given my user to http://www.mysite.com, I'm able to achieve this by rewriting following lines in my .htaccess fileRewritecond %{http_host} ^mysite.comRewriteRule ^(.*) http://www.mysite.com/$1 [R=301,L]But I want do this from Apache,So I've added following line in Virtual host conf file of the site and removed above two lines from .htaccessRedirect 301 / http://mysite.com/But whenever I'm trying to access the site following error is displyaing,Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.where I'm doing the wrong ?
Issue with Apache redirection
htaccess;mod rewrite;apache2
What you want is this:RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]RewriteCond %{HTTP_HOST}   !^$RewriteRule ^/(.*)         http://www.example.com/$1 [L,R]which was copied directly from here. You really ought to read through that page and understand it.Your current rewrite rule, as it stands, sends every request to a local server path that your apache config probably cannot deliver ('/' is the root directory of your server not the root of your website). Apache in turn will try to respond to that with an error page, which in turn gets redirected to the '/' again, hence an infinite redirect.The above code only redirects requests NOT bound for www.example.com and preserves the rest of the URL when it redirects.