Solved

Website URL redirection

Posted on 2016-10-06
10
52 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 49

Expert Comment

by:Ryan Chong
Comment Utility
0
 
LVL 2

Expert Comment

by:Alex Smith
Comment Utility
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
Comment Utility
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
 
LVL 2

Expert Comment

by:Alex Smith
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:Alex Smith
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now