?
Solved

dynamically add www before my domain name url

Posted on 2009-12-29
4
Medium Priority
?
263 Views
Last Modified: 2012-05-08
When some one types in mydomain.com/about.aspx I need to dynamically place www. before the domain name if it is not present: www.mydomain.com/about.aspx. Can some one tell me the best way to accomplish this?

Thanks.
0
Comment
Question by:RCairns54
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ICaldwell
ID: 26141204
This is usually something controlled at the web server.... one web server is just setup to take every request, add the www. onto it and then post back, this can be done in a request string....

Question is do you want to take this much time to do it or just setup your main website with your IP of your server and set an alias for www to your main server, that way both ways will work.

Personally I would not redirect users but let them have the option of having it or not, both will work...
0
 

Author Comment

by:RCairns54
ID: 26141455
Thanks for your quick reply.

I have iis set up to handle both the domain and the www subdomain requests, but for seo reasons I need to have the www in the url every time. I have used 301 redirects but this is pretty static and takes you to one base url. I thought about handling the request at the app level, caching the url and adding www to the string and redirect but I was hoping to find a way to do this outside of the web app.

Here is an example of what I'm looking for:
If you go to www.bing.com and preform a search and then delete the www. off the url and hit enter it adds it back. This is basically the effect Im looking for.
0
 
LVL 11

Accepted Solution

by:
ICaldwell earned 2000 total points
ID: 26141870
are you using IIS 7?  If so you could use the URL rewriting to redirect non www to www...

http://weblogs.asp.net/owscott/archive/2009/11/27/iis-url-rewrite-rewriting-non-www-to-www.aspx

This is from the article and I think is exactly what your looking for:

For the Action Properties, enter http://www.domain.com/{R:0}.  The {R:0} retains the existing URL so if someone typed something like http://domain.com/aboutus it would retain the aboutus as it adds the www
0
 

Author Closing Comment

by:RCairns54
ID: 31670947
Sweet. Thanks for pointing me in the right direction.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question