Are you a Google Analytics enthusiast?
Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE!

www.CustomReportSharing.com
From the folks who brought you High Rankings!
More SEO Content
Another Redirection Issue
#16
Posted 12 September 2006 - 03:25 PM
We are finally ready to rollout our new site on Monday. I have a couple of additional questions regarding this topic if you don't mind.
1. How long (rough estimate) will we need to leave the server.transfer solution in place if we go that route?
2. If we decide to go with the 301 redirect (still using the code sample you provided with the array), any idea on the length of time (rough estimate) it would take Google to index our new .aspx files?
Thanks again for all of your help. I really appreciate it!
#17
Posted 12 September 2006 - 07:06 PM
2/ a few weeks normally.
#18
Posted 02 March 2007 - 06:33 AM
See http://www.tek-tips....d...1205&page=1 for the issues raised.
Redirect 2000 (ver 2.54) has been replaced with Redirect XP see below
Edited by chrishirst, 06 March 2007 - 07:10 PM.
#19
Posted 06 March 2007 - 12:14 PM
1) Looks like you have a typo on this line:
if instr(request.servervariables("QUERY_STRING"), pageArray(i,0)) > 0 then
The (i,0) should be (0,i)......I noticed your posting on the other message board was correct......man, I couldn't for the life of me figure out why I pasted that one and it worked, and this one and it didn't....so I compared the two and found that.
2) Any way to get the server response for the 301 to not include the :80 in the address?
3) As for #2, does the server port matter when it comes to 301 redirects and SEO?
4) Lastly, I'm assuming that if I want to 301 redirect a user from a specific page, to the root of the site (because I don't want them to go to the default page in the url), I can use the following:
pageArray(0,0) = "badpage.php"
pageArray(0,1) = " "
Using a space for the page to send them to....essentially taking them to the root of the site. I tried no space and a / but neither worked.
Awesome script.....I know we can always count on you to solve those complex ASP problems!
-Kevin
#20
Posted 06 March 2007 - 04:44 PM
If the port number is included use a replace(newURI,":80","") to strip it out.
the port number will only matter if you are using a non-standard port for the HTTP server otherwise 80 is the default
A space should be perfectly ok and a empty string ("") should as well, using a "/" will result in www.domain.tld// which may result in the server trying to redirect to a folder with no name (theoretically)
#21
Posted 06 March 2007 - 05:19 PM
If the port number is included use a replace(newURI,":80","") to strip it out.
the port number will only matter if you are using a non-standard port for the HTTP server otherwise 80 is the default
A space should be perfectly ok and a empty string ("") should as well, using a "/" will result in www.domain.tld// which may result in the server trying to redirect to a folder with no name (theoretically)
I added:
newURI = replace(newURI,":80","")
That works perfectly to remove the :80
The server is running on port 80, I just wasn't sure how Google and the other SE's would see the 301 to a url with the :80 in it.
As for the empty string (""), it works ONLY when it matches one of the pages in the array. The script doesn't work for serving the general 404 error page if you use an empty string. The only thing that works both ways is the space (" ").
-Kevin
#22
Posted 06 March 2007 - 07:06 PM
It transpires in VbScript that when you run an instr() comparison against a empty variable it returns a value of 1 rather than 0 which would be expected. So the script returns bFound as True even though there is no match.
so Redirect XP (Ver 3.21) is below
dim i, newURI, req, pageArray(1,50)
pageArray(0,0) = "/dir/pagename.htm"
pageArray(1,0) = "/dir/pagename.asp"
bFound = false
for i = 0 to ubound(pageArray,2)
if pagearray(0,i) <> "" then
if instr(request.servervariables("QUERY_STRING"), pageArray(0,i)) <> 0 then
req = replace(request.servervariables("QUERY_STRING"),"404;","")
newURI = replace(req,pageArray(0,i), pageArray(1,i))
bFound = true
end if
end if
if bFound then exit for
next
if bFound then
' uncomment the next line to keep the original URI but show the new content
'server.transfer("/newdir/" & pageArray(1,i))
'server.transfer(pageArray(1,i))
' uncomment the next lines to redirect to the new pagename
response.status = "301 Moved Permanently"
response.addheader "Location", newURI
response.end()
else
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Not Found</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
This is the 404 page
<body>
</body>
</html>
<%
response.status = "404 Not Found"
response.end
end if
%>
To answer the point about having :80 in the URL
Technically it would make no difference to accessing the site , however it would be a different URL to search engines so would create the same issues as having default.asp in the URLs or the www vs non-www issues.
#23
Posted 06 March 2007 - 07:30 PM
pageArray(0,0) = "/dir/pagename.htm"
pageArray(1,0) = "/dir/pagename.asp"
I was under the impression that the first line is the page you are checking, and the second is the page you are 301'ing to.
1) Can you add more pages to go to different 301'd pages?
2) In your previous script, the 2nd line the array was (0,1), and now it's (1,0)....why?
Thanks for taking the time to troubleshoot this.....you've been a huge help!
-Kevin
#24
Posted 06 March 2007 - 07:56 PM
to continue the array would be
pageArray(0,0) = "/dir/pagename.htm"
pageArray(1,0) = "/dir/pagename.asp"
pageArray(0,1) = "/dir/anotherpage.htm"
pageArray(1,1) = "/dir/anotherpage.asp"
and so on
and for 2/ I have this script in a slightly different form for one site and pull the URIs from a database with a ADO GetRows() this creates the array dynamically , and I got the definitions opposite way around when I converted it to a static array.
It's one of the dumb things you do sometimes when you don't think about code anymore and just type it from memory.
At least I don't do hexadecimal maths in my head anymore
#25
Posted 06 March 2007 - 09:07 PM
I'm assuming in VB that if you have this:
pageArray(0,0) = "oldpage.php"
and nothing else, it assumes that the second part of the array (1,0) is an empty string, therefore, it will take you to the root?
Just checking.
It works great though, thank you so much.
-Kevin
#26
Posted 07 March 2007 - 12:44 PM
Thanks very much for this updated script - it's implemented and working very nicely now. As far as I know, this is the only(?) ASP solution to modifying site pages if you don't have full access to the IIS console (we're hosted on a shared environment).
Cheers,
Rob
#27
Posted 10 April 2007 - 06:09 PM
I have a quick question on the array.
Is there any way to include a wildcard character in the array. For example, let's say I need to redirect the following pages:
testing_100.html
testing_101.html
testing_102.html
Basically any page that matches testing_*.html
And send them all to a single new page.
Is this possible without adding an entry for each page?
-Kevin
#28
Posted 11 April 2007 - 09:24 AM
simplest would be to use a regular expression,
function code
dim objRE
set objRE = New RegExp
objRE.pattern = "\b(testing_).*?(\.html)"
objRE.Global = True
ReplacePageName = objRE.replace(strIn,"pagename.html")
set objRE = nothing
end function
then after the "next" add
req = replace(request.servervariables("QUERY_STRING"),"404;","")
newURI = ReplacePageName(req)
bFound = true
end if
Edited by chrishirst, 11 April 2007 - 02:40 PM.
fixed the unbalanced paranthesis
#29
Posted 11 April 2007 - 12:44 PM
simplest would be to use a regular expression,
Chris,
I'm getting the following error:
Expected 'Then'
/error.asp, line 126
if instr(request.servervariables("QUERY_STRING"), "testing_")) <> 0 then
--------------------------------------------------------------^
Any ideas?
-Kevin
#30
Posted 11 April 2007 - 02:40 PM
there is an extra ")" that snuck in there
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users








