Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:48:32+00:00 2026-05-29T05:48:32+00:00

I have a solution writted in C# in VS2010. When I type http://www.mywebsite.com in

  • 0

I have a solution writted in C# in VS2010. When I type http://www.mywebsite.com in my browser, I am able to display my website successfully. When I type http://mywebsite.com in my browser, I am able to display my website but with some CSS problems. Because in my code I have some settings file where my website is recognised as ‘http://www.mywebsite.com’. That’s the story.

My question is: if user is typing http://mywebsite.com is there a way to redirect to http://www.mywebsite.com?

For example, if you type http://google.com it is automatically redirected to http://www.google.com

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:48:33+00:00Added an answer on May 29, 2026 at 5:48 am

    Add this to web.config:

    <rewrite>
    <rules>
        <rule name="Redirect mywebsite.com to www" patternSyntax="Wildcard" stopProcessing="true">
            <match url="*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="mywebsite.com" />
            </conditions>
            <action type="Redirect" url="http://www.mywebsite.com/{R:0}" />
        </rule>
    </rules>
    </rewrite>
    

    In code-behind, you can also use something like (not tested)

    if(!Request.Url.Host.StartsWith("www"))
        Response.Redirect("http://www.mysite.com/" + Request.Url.LocalPath);
    

    but that would have to be on every page on on the MasterPage (if you have one) or slightly altered in Global.asax

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing this problem: http://www.codechef.com/problems/FCTRL I have the solution, but, the memory usage is
I have a solution to the below problem in PHP. But it is taking
EDIT: I now have a solution, but I'd really apprecite a concise description of
Does anyone have a solution for a basic, compact Finite state machine/automata written in
Currently I have solution A that contains a domain layer base and solution B
I have a solution with several projects. One of them is a setup project.
I have a solution with many projects. One project contain few custom components. One
I have a solution consisting of five projects, each of which compile to separate
I have a solution with several projects, where the startup project has a post-build
I have a solution in Visual Studio 2005(professional Edition) which in turn has 8

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.