The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. 301 Redirect with ASP (not .NET)

    301 Redirect with ASP (not .NET)

    Technical SEO Issues
    2 1 550
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Hughescov
      Hughescov last edited by

      I'm looking to redirect non www to www and also .co.uk to .com.

      http://www.xxxxx.com is the intended target.

      http://xxxxx.com & http://www.xxxxx.co.uk & http://xxxxx.co.uk to redirect.

      I managed to do some of this but if I come through to a service page /services/cars.asp it redirects to the homepage.

      All I have so far is this code:

      <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 ThenResponse.write "http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING")Response.EndEnd if %>

      What am I missing?

      1 Reply Last reply Reply Quote 0
      • Hughescov
        Hughescov last edited by

        Ok I figured it out for anyone that wants to know.

        <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.xxxxx.com" & request.ServerVariables("URL") & Request.ServerVariables("QUERY_STRING") Response.End

        Else If

        InStr(Request.ServerVariables("SERVER_NAME"),"xxxxx.com") = 0 then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www.xxxxx.com" & request.ServerVariables("URL") & Request.ServerVariables("QUERY_STRING") Response.End end if

        End if %>

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        • 301 Redirects
          imoprojects
          imoprojects
          0
          7
          138

        • Does any one have experience with SEO and .NET using 301 redirects?
          TomRayner
          TomRayner
          0
          2
          130

        • Where is the 301 redirect?
          JarnoNijzing
          JarnoNijzing
          0
          2
          189

        • 301 redirects reverting to 302 redirects
          Devanur-Rafi
          Devanur-Rafi
          0
          6
          532

        • To 301 redirect or not to 301 redirect? duplicate content problem www.domain.com and www.domain.com/en/
          Chris-CA
          Chris-CA
          0
          5
          456

        • 301 Redirect Domain or 301 Redirect Domain + Interior Pages
          Room214
          Room214
          0
          7
          1.1k

        • 301-redirect
          KeriMorgret
          KeriMorgret
          0
          14
          1.0k

        • 301 redirects
          IM_Learner
          IM_Learner
          0
          2
          759

        Get started with Moz Pro!

        Unlock the power of advanced SEO tools and data-driven insights.

        Start my free trial
        Products
        • Moz Pro
        • Moz Local
        • Moz API
        • Moz Data
        • STAT
        • Product Updates
        Moz Solutions
        • SMB Solutions
        • Agency Solutions
        • Enterprise Solutions
        • Digital Marketers
        Free SEO Tools
        • Domain Authority Checker
        • Link Explorer
        • Keyword Explorer
        • Competitive Research
        • Brand Authority Checker
        • Local Citation Checker
        • MozBar Extension
        • MozCast
        Resources
        • Blog
        • SEO Learning Center
        • Help Hub
        • Beginner's Guide to SEO
        • How-to Guides
        • Moz Academy
        • API Docs
        About Moz
        • About
        • Team
        • Careers
        • Contact
        Why Moz
        • Case Studies
        • Testimonials
        Get Involved
        • Become an Affiliate
        • MozCon
        • Webinars
        • Practical Marketer Series
        • MozPod
        Connect with us

        Contact the Help team

        Join our newsletter
        Moz logo
        © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
        • Accessibility
        • Terms of Use
        • Privacy