Solved

Website URL redirection

Posted on 2016-10-06
10
72 Views
Last Modified: 2016-10-12
I'm using IIS for a website but I have a redirection issue

If i enter the URL www.site.com/buyproducts it takes me to www.site.com/buyproducts however if I don't enter the www and just site.com/buyproducts it takes me to www.site.com.

Where would change the settings so that it will take me to www.site/com/buyproducts or site.com/buyproducts depending on which I enter?

Thanks
0
Comment
Question by:jdr0606
  • 5
  • 4
10 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 41832977
0
 
LVL 2

Expert Comment

by:Alex Smith
ID: 41832982
To redirect yourdomain.com to www.yourdomain.com, edit your web.config file and add the below segment under the <system.webserver> section. Ensure you modify the words “yourdomain.com” with your appropriate domain name.

<rewrite>
      <rules>
            <rule name="Redirect http://yourdomain.com to http://www.yourdomain.com HTTP" patternSyntax="ECMAScript" stopProcessing="true">
          <match url=".*"></match>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^yourdomain.com$"></add>
            <add input="{HTTPS}" pattern="off"></add>
          </conditions>
          <action type="Redirect" url="http://www.yourdomain.com/{R:0}" redirectType="Permanent" appendQueryString="true"></action>
        </rule>
      </rules>
    </rewrite>

Open in new window

0
 

Author Comment

by:jdr0606
ID: 41832988
I'm not sure I was clear on my original email

What I want to happen is:

If I enter www.site.com/buyproducts I want it to go to www.site.com/buyproducts

but if I enter site.com/buyproducts I want it to go to site.com/buyproducts

Thanks
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 2

Expert Comment

by:Alex Smith
ID: 41832992
As per Google or other search engine, you can use only one way of URL, It can be with www or without www.

If you using both Google can penalizes the website as duplicate content.

So first you must be finalize which domain you want to carry on.
0
 

Author Comment

by:jdr0606
ID: 41832993
Thanks for the info Alex

So let me look at it differently

If I enter www.site.com/buyproducts I want it to go to www.site.com/buyproducts

but if I enter site.com/buyproducts I want it to go to www.site.com/buyproducts
0
 
LVL 2

Expert Comment

by:Alex Smith
ID: 41832995
Perfect.

Now you can follow my first comment to resolve the issue.

Need any help feel free to contact.

Alex
0
 

Author Comment

by:jdr0606
ID: 41833011
Alex, as you can probably tell, i'm not very proficient with web.config or rewrite syntax.  I tried adding the code you suggested but it then generated a 500 error.  I likely need to replace rather than add to my existing rewrite but not sure where.

Here is what I have now under the rewrite section

        <rewrite>
            <rules>
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^morecatalogs$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="morecatalogs.aspx" />
                </rule>
                <rule name="morecatalogs with slash">
                    <match url="morecatalogs/" />
                    <action type="Rewrite" url="morecatalogs.aspx" />
                </rule>
            </rules>
        </rewrite>
0
 
LVL 2

Accepted Solution

by:
Alex Smith earned 500 total points
ID: 41833048
Hi,

replace yourdomain.com with your actual domain name. and upload it.

or

share your domain or url which you want to redirect i can help you on redirect syntax.
0
 

Author Comment

by:jdr0606
ID: 41833620
This is what I entered, however when I enter kele.com/smartbuy it redirects to www.kele.com

Do I need to look at something in IIS as well?

       <rewrite>
            <rules>
                <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                    <match url="^morecatalogs$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="morecatalogs.aspx" />
                </rule>
                <rule name="morecatalogs with slash">
                    <match url="morecatalogs/" />
                    <action type="Rewrite" url="morecatalogs.aspx" />
                </rule>
<!-- Entered this URL 2016-10-06 -->
            <rule name="Redirect http://kele.com to http://www.kele.com HTTP" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".*"></match>
                <conditions>
                        <add input="{HTTP_HOST}" pattern="^yourdomain.com$"></add>
                        <add input="{HTTPS}" pattern="off"></add>
                </conditions>
          <action type="Redirect" url="http://www.kele.com/{R:0}" redirectType="Permanent" appendQueryString="true"></action>
              </rule>

            </rules>
        </rewrite>
0
 
LVL 2

Expert Comment

by:Alex Smith
ID: 41841382
Hi,

If you want to redirect the single page than you can also place the below given meta tag to your kele.com/smartbuy page header.

<meta http-equiv="refresh" content="01; ,URL=http://www.kele.com">

Please let me know have any issue.

Alex
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

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