Solved

Website URL redirection

Posted on 2016-10-06
10
68 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

770 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