Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

non-www to www redirect works with a little issue

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


joydeep at infoservices

May 25, 2012, 3:53 AM

Post #1 of 3 (215 views)
Permalink
non-www to www redirect works with a little issue

Hello,

I have place the following in my .htaccess to redirect non-www to www redirection

`````````````
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*) http://www.example.com/$1 [R=301]

```````````````

The redirect work well but a little hitch.
Say If I visit http://example.com/page1.html it redirect to
http://www.example.com so at the home page. Where it should
append the www before the link, but not alter the link.

What modification should I add here to make it work ?

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


joydeep at infoservices

May 25, 2012, 4:50 AM

Post #2 of 3 (204 views)
Permalink
Re: Solved non-www to www redirect works with a little issue [In reply to]

Solved :-)

RewriteRule ^(.*) http://www.example.com/%{REQUEST_URI} [R=301]


On Fri, 25 May 2012 16:23:29 +0530
"J. Bakshi" <joydeep [at] infoservices> wrote:

> Hello,
>
> I have place the following in my .htaccess to redirect non-www to www redirection
>
> `````````````
> RewriteCond %{HTTP_HOST} ^example\.com$
> RewriteRule ^(.*) http://www.example.com/$1 [R=301]
>
> ```````````````
>
> The redirect work well but a little hitch.
> Say If I visit http://example.com/page1.html it redirect to
> http://www.example.com so at the home page. Where it should
> append the www before the link, but not alter the link.
>
> What modification should I add here to make it work ?
>
> Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd


clay.porter at gmail

May 26, 2012, 1:08 PM

Post #3 of 3 (202 views)
Permalink
Re: non-www to www redirect works with a little issue [In reply to]

This works for us.

RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule .* http://www.example.com%{REQUEST_URI} [R=301,L]

On Fri, May 25, 2012 at 6:53 AM, J. Bakshi <joydeep [at] infoservices> wrote:
> Hello,
>
> I have place the following in my .htaccess to redirect non-www to www redirection
>
> `````````````
> RewriteCond %{HTTP_HOST} ^example\.com$
> RewriteRule ^(.*) http://www.example.com/$1 [R=301]
>
> ```````````````
>
> The redirect work well but a little hitch.
> Say If I visit http://example.com/page1.html it redirect to
> http://www.example.com so at the home page. Where it should
> append the www before the link, but not alter the link.
>
> What modification should I add here to make it work ?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.