301 Redirect ASP code
-
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`
-
Thank you
-
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...
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
How to 301 redirect from old domain and their pages to new domain and pages?
Hi i am a real newbie to this and i hope for a guide on how to do this. I seen a few moz post and is quiet confusing hopefully somebody able to explain it in layman terms to me. I would like to 301 redirect this way, both website contain the same niche. oldwebsite.com > newwebsite.com and also its pages..... oldwebsite.com/test >newwebsite.com/test So my question here is i would like to host my old domain and its pages in my new website hosting in order to redirect to my new domain and its pages how do i do that? would my previous page link overwrite my new page link? or it add on the juice link? Do i need to host the whole old domain website into my new hosting in order to redirect the old pages? really confusing here, thanks!
White Hat / Black Hat SEO | | andzon0 -
Suspicious external links to site have 302 redirects
Hi, I have been asked to look at a site where I suspect some questionable SEO work, particularly link building. The site does seem to be performing very poorly in Google since January 2014, although there are no messages in WMT. Using WMT, OPenSiteExplorer, Majestic & NetPeak, I have analysed inbound links and found a group of links which although are listed in WMT, etc appear to 302 redirect to a directory in China (therefore the actual linking domain is not visible). It looks like a crude type of link farm, but I cant understand why they would use 302s not 301s. The domains are not visible due to redirects. Should I request a disavow or ignore? The linking domains are listed below: http://www.basalts.cn/
White Hat / Black Hat SEO | | crescentdigital
http://www.chinamarbles.com.cn/
http://www.china-slate.com.cn/
http://www.granitecountertop.com.cn/
http://www.granite-exporter.com/
http://www.sandstones.biz/
http://www.stone-2.com/
http://www.stonebuild.cn/
http://www.stonecompany.com.cn/
http://www.stonecontact.cn/
http://www.stonecrate.com/
http://www.stonedesk.com/
http://www.stonedvd.com/
http://www.stonepark.cn/
http://www.stonetool.com.cn/
http://www.stonewebsite.com/ Thanks Steve0 -
Could lots of links pointed to 301 & 302 redirects be a problem?
Hello, We've got hundreds of links found in screaming frog that are pointing towards 301 & 302 redirects. Could this be hurting rankings? We've got very few 404s. A lot of the problem is breadcrumbs of categories pointing to 302s, but the original category pages that are 302ed are not indexed so we may be OK. We can't change the 302 redirects, it's part of the cart. Could all these non-updated hyperlinks be the cause of continual ranking drop in Google? We've gone from the top 3 to the second page for our main terms. Thanks!
White Hat / Black Hat SEO | | BobGW0 -
What is the difference between using .htaccess file and httpd.conf in implementing thousands of 301 redirections?
What is the best solution in terms of website loading time or server load? Thanks in advance!
White Hat / Black Hat SEO | | esiow20130 -
301 redirect a set of pages to one landing page/URL?
I'm planning to redirect the following pages to one new URL/landing page: Old URLs: http://www.olddomain.com/folder/page/1 http://www.olddomain.com/folder/page/2 http://www.olddomain.com/folder/page/3 http://www.olddomain.com/folder/page/4 http://www.olddomain.com/folder/page/5 http://www.olddomain.com/folder/page/6 New URL: http://www.newdomain.com/new-folder/new-page Code in .htaccess that I will be using: RedirectMatch 301 /folder/page/(.*) http://www.newdomain.com/new-folder/new-page Let me know if this is correct. Thanks!
White Hat / Black Hat SEO | | esiow20130 -
Redirect n domain to one
What happen when I redirect301 10 domain to one? I have 10 domain with ave Page Authority=45 and Domain Authority 60 and want to increase my new domain by redirect them. is it right or wrong?
White Hat / Black Hat SEO | | vahidafshari450 -
If I redirect a penalized domain to a non-penalized domain, will the new domain still be penalized?
If I redirect a penalized domain to a non-penalized domain, will the new domain still be penalized?
White Hat / Black Hat SEO | | MangoMan160 -
Redirecting doesn't rank on google
We are redirecting our artist's official website to copenhagenbeta.dk. We have two artists (Nik & Jay and Burhan G) that top ranks on Google (first on page 1), but one of them (Lukas Graham) doesn't rank at all. We use the same procedure with all artists. http://copenhagenbeta.dk/index.php?option=com_artistdetail&task=biography&type=overview&id=49 Doesn't rank but the old artist page still does. Is it the old page that tricks Google to think that this is the active page for the artist?
White Hat / Black Hat SEO | | Morten_Hjort0