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. White Hat / Black Hat SEO
    4. 301 Redirect ASP code

    301 Redirect ASP code

    White Hat / Black Hat SEO
    3 2 636
    • 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.
    • TwoPints
      TwoPints last edited by

      Hi

      I have a script detailed below, that 301 redirects based upon different queries ---

      """"<%if (Request("offset")     = "") Then%> <% if Request("keywords") = "" AND Request("s") <> "" AND Request("j") <> "" then'Sector and Location NOT NULL%> <% if (Request.ServerVariables("HTTP_X_REQUEST_URI")) <> "/" & LCase(SEOFriend(replaces.Fields.Item("JBCategoryLabel"))) & "-jobs-in-" & LCase(SEOFriend(replacej.Fields.Item("JBLocation"))) Then Response.Status="301 Moved Permanently" Response.AddHeader "Location", "/" & LCase(SEOFriend(replaces.Fields.Item("JBCategoryLabel"))) & "-jobs-in-" & LCase(SEOFriend(replacej.Fields.Item("JBLocation"))) Response.End End If %> <%End if%> <% if Request("keywords") = "" AND Request("s") <> "" AND Request("j") = "" then'Sector NOT NULL and Location NULL %> <% if (Request.ServerVariables("HTTP_X_REQUEST_URI")) <> "/" & LCase(SEOFriend(replaces.Fields.Item("JBCategoryLabel"))) & "-jobs-in-" & LCase(SEOFriend(SiteDetails.Fields.Item("JBSRegion"))) Then Response.Status="301 Moved Permanently" Response.AddHeader "Location", "/" & LCase(SEOFriend(replaces.Fields.Item("JBCategoryLabel"))) & "-jobs-in-" & LCase(SEOFriend(SiteDetails.Fields.Item("JBSRegion"))) Response.End End If %> <%End if%> <% if Request("keywords") = "" AND Request("s") = "" AND Request("j") <> "" then'Sector NULL and Location NOT NULL %> <% if (Request.ServerVariables("HTTP_X_REQUEST_URI")) <> "/jobs-in-" & LCase(SEOFriend(replacej.Fields.Item("JBLocation"))) Then Response.Status="301 Moved Permanently" Response.AddHeader "Location", "/jobs-in-" & LCase(SEOFriend(replacej.Fields.Item("JBLocation"))) Response.End End If %> <%End if%> <%End if%>""""

      But this still allows for both the www and non www versions of these pages to render in the browser, which is resulting in duplicate content.

      On my home page I use --

      <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://www." & Request.ServerVariables("HTTP_HOST") & "/" Response.End End if %>

      `Is there a good way to combine these, so that I still get all of the rules of the first script whilst also redirecting any non www versions to the www version?

      in other words
      domain.com/jobs-in-" & LCase(SEOFriend(replacej.Fields.Item("JBLocation")))
      Eould redirect to
      www.domain.com/jobs-in-" & LCase(SEOFriend(replacej.Fields.Item("JBLocation")))

      Thanks in advance`

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

        I don't know if I understood coorrectely, but I think the follow:

        Redirect example.com to www.example.com RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L]

        Redirect especific page redirect 301 /old.html http://www.example.com/new.html

        I holpe this is what you are looking for...

        TwoPints 1 Reply Last reply Reply Quote 1
        • TwoPints
          TwoPints @Naghirniac last edited by

          Thank you

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          • 301 Redirect Backlinks from Forbes,CNN.
            Hardcoretech
            Hardcoretech
            0
            7
            522

          • Problems in 301 redirections
            esiow2013
            esiow2013
            0
            4
            99

          • What is the difference between Redirect 301 and RedirectMatch 301 in .htaccess?
            Devanur-Rafi
            Devanur-Rafi
            0
            2
            12.9k

          • URL structure: 301 redirect or leave as is?
            stever999
            stever999
            0
            3
            102

          • 301 Redirect Asp.net Help
            CityWonders
            CityWonders
            0
            2
            139

          • 2 Questions about 301 Redirects
            kchandler
            kchandler
            0
            3
            153

          • Does 301 redirection will effect my site in the future?
            NakulGoyal
            NakulGoyal
            0
            4
            383

          • Use of 301 redirects
            AlanMosley
            AlanMosley
            0
            3
            446

          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