Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

Redirect for missing 'www' in URL

 
   Web Hosting and Web Master Forums (Home) -> Apache RSS
Next:  IIS 6 : ASP HANG NOT HTML  
Author Message
weeged

External


Since: Nov 17, 2004
Posts: 2



(Msg. 1) Posted: Mon Feb 28, 2005 1:45 am
Post subject: Redirect for missing 'www' in URL
Archived from groups: alt>apache>configuration (more info?)

Hi, is there anyway I can redirect a user who has forgotten to enter
the www part at the beginning of a URL?

i.e I want to direct a user to the same content whether they enter
mysite.com or www.mysite.com

I'm using name-based virtual hosting and any help would be
appreciated.

Regards
Chris

 >> Stay informed about: Redirect for missing 'www' in URL 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 2) Posted: Mon Feb 28, 2005 6:35 am
Post subject: Re: Redirect for missing 'www' in URL [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

this post is not archived.

 >> Stay informed about: Redirect for missing 'www' in URL 
Back to top
Login to vote
hans1

External


Since: Mar 29, 2004
Posts: 672



(Msg. 3) Posted: Mon Feb 28, 2005 8:35 am
Post subject: Re: Redirect for missing 'www' in URL [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Chris" <weeged.RemoveThis@gmail.com> schreef in bericht
news:4d39f7c0.0502280145.b2f22c2@posting.google.com...
 > Hi, is there anyway I can redirect a user who has forgotten to enter
 > the www part at the beginning of a URL?
 >
 > i.e I want to direct a user to the same content whether they enter
<font color=purple> > mysite.com or <a style='text-decoration: underline;' href="http://www.mysite.com</font" target="_blank">www.mysite.com</font</a>>
First things first, both names has to resolve over DNS to the same IP.

 > I'm using name-based virtual hosting and any help would be
 > appreciated.
I'm using a rewrite in the _default_ virtual host:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www)\.
RewriteCond %{HTTP_HOST} ^([^\.]+\.)?([^\.]+\.[^\.]+)$
RewriteRule (.*) <a style='text-decoration: underline;' href="http://www.%2$1?d=1" target="_blank">http://www.%2$1?d=1</a> [R=301,QSA,L]

The 'd=1' is only a reference logged with the redirected request by the
proper vhost.
( 'Using another Rewrite at the same vhost to take care of spelling errors
.... like <a style='text-decoration: underline;' href="http://www.misite.com" target="_blank">www.misite.com</a> or <a style='text-decoration: underline;' href="http://www.myside.com" target="_blank">www.myside.com</a> and adds 'd=2' as marker )

For the default vhost you may want to append the host name to the log
LogFormat "%h %l %u ....... \"%{host}i\"" combined-host

HansH<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Redirect for missing 'www' in URL 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Missing Something - I have a problem I am sure everyone has heard a hundred times. I want to setup Virtual Host using one Ip address. The DNS for both domains points to the server. Server name is webserver.x.com The two domains I want to host are www.z.com, www.w.com. In th...

Am I missing something here? - I am running Apache 1.3.29/PhP 4.3.4. After install all works well, but when I add the virtual server for my Pinnacle Showcenter in httpd.conf using the entries below I can no longer the 'regular' server at port 80, I get page not found errors. I'm..

apr packages missing - While trying to install httpd 2.0.47-6 the two packages apr-devel and apr-util-devel are missing, downloading the source for apr from apr.apache.org I'm still missing apr-devel and apr-util-devel . Where is the apr-devel and apr-util-devel source at?..

Configuring DAV - something's missing - I'm trying to get DAV to work, using the apache2 docs and this tutorial: http://httpd.apache.org/docs-2.0/mod/mod_dav.html http://www.serverwatch.com/tutorials/article.php/10825_2176771_2 Seems like a pretty straightforward setup. In httpd2.conf I have...

How to set Missing.html for the error page - I have created a missing.html file in my document root (http://www.machilus.com/missing.html) and made the following configuration: #ErrorDocument 500 "The server made a boo boo. # n.b. the single leading (") marks it as text, it does not ge...
   Web Hosting and Web Master Forums (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]