High Rankings Search Engine Optimization ForumHigh Rankings Advisor Search Marketing Newsletter

Welcome Guest ( Log In | Register )

Important Announcement: *Written SEO Website Reviews Available*
3 Pages V  < 1 2 3 >  
Reply to this topicStart new topic
> Another Redirection Issue, Redirection of .htm pages
Pacerfan
post Sep 12 2006, 03:25 PM
Post #16


HR 1
*

Group: Members
Posts: 5
Joined: 1-June 06
User's local time:
Jul 31 2010, 07:53 PM
Member No.: 11,975



Hi Chrishirst,

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!
Go to the top of the page
 
+Quote Post
chrishirst
post Sep 12 2006, 07:06 PM
Post #17


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



1/ permanently

2/ a few weeks normally.
Go to the top of the page
 
+Quote Post
chrishirst
post Mar 2 2007, 06:33 AM
Post #18


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



Rectified the code after some bugs found
See http://www.tek-tips.com/viewthread.cfm?qid...1205&page=1 for the issues raised.
Redirect 2000 (ver 2.54) has been replaced with Redirect XP see below
CODE
Code eaten by the bugs


This post has been edited by chrishirst: Mar 6 2007, 07:10 PM
Go to the top of the page
 
+Quote Post
kblm
post Mar 6 2007, 12:14 PM
Post #19


HR 2
**

Group: Members
Posts: 13
Joined: 29-September 06
User's local time:
Jul 31 2010, 06:53 PM
Member No.: 14,128



Chris, couple of things,

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
Go to the top of the page
 
+Quote Post
chrishirst
post Mar 6 2007, 04:44 PM
Post #20


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



QUOTE
Looks like you have a typo on this line:
doesn't surprise me, at one point I had 4 different bits of code on the go, I've corrected it now here as well.

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)
Go to the top of the page
 
+Quote Post
kblm
post Mar 6 2007, 05:19 PM
Post #21


HR 2
**

Group: Members
Posts: 13
Joined: 29-September 06
User's local time:
Jul 31 2010, 06:53 PM
Member No.: 14,128



QUOTE(chrishirst @ Mar 6 2007, 04:44 PM) *
doesn't surprise me, at one point I had 4 different bits of code on the go, I've corrected it now here as well.

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
Go to the top of the page
 
+Quote Post
chrishirst
post Mar 6 2007, 07:06 PM
Post #22


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



Ok retested the code because this
QUOTE
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 (" ").
shouldn't happen because no array match should drop through to the ... else thus displaying the error page and return the 404 response to the User Agent.

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
CODE
<%
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
%>
Test to destruction to see if I have still missed something.

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.
Go to the top of the page
 
+Quote Post
kblm
post Mar 6 2007, 07:30 PM
Post #23


HR 2
**

Group: Members
Posts: 13
Joined: 29-September 06
User's local time:
Jul 31 2010, 06:53 PM
Member No.: 14,128



Chris, I don't know VB that well.....can you explain this section:

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
Go to the top of the page
 
+Quote Post
chrishirst
post Mar 6 2007, 07:56 PM
Post #24


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



QUOTE
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.
That,s correct
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. (IMG:http://www.highrankings.com/forum/style_emoticons/default/mf_type.gif) (IMG:http://www.highrankings.com/forum/style_emoticons/default/mf_prop.gif) (IMG:http://www.highrankings.com/forum/style_emoticons/default/nerd.gif)


Offtopic

At least I don't do hexadecimal maths in my head anymore (IMG:http://www.highrankings.com/forum/style_emoticons/default/hmm.gif)
Go to the top of the page
 
+Quote Post
kblm
post Mar 6 2007, 09:07 PM
Post #25


HR 2
**

Group: Members
Posts: 13
Joined: 29-September 06
User's local time:
Jul 31 2010, 06:53 PM
Member No.: 14,128



Chris......you rock. Thanks!

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
Go to the top of the page
 
+Quote Post
lastdonuk
post Mar 7 2007, 12:44 PM
Post #26


HR 1
*

Group: Members
Posts: 1
Joined: 7-March 07
User's local time:
Aug 1 2010, 12:53 AM
Member No.: 16,472



Chris,

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
Go to the top of the page
 
+Quote Post
kblm
post Apr 10 2007, 06:09 PM
Post #27


HR 2
**

Group: Members
Posts: 13
Joined: 29-September 06
User's local time:
Jul 31 2010, 06:53 PM
Member No.: 14,128



Chris,

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
Go to the top of the page
 
+Quote Post
chrishirst
post Apr 11 2007, 09:24 AM
Post #28


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



it certainly can

simplest would be to use a regular expression,

function code
CODE
function ReplacePageName(strIn)
    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
CODE
    if instr(request.servervariables("QUERY_STRING"), "testing_") <> 0 then
        req = replace(request.servervariables("QUERY_STRING"),"404;","")
          newURI = ReplacePageName(req)
           bFound = true
     end if


This post has been edited by chrishirst: Apr 11 2007, 02:40 PM
Reason for edit: fixed the unbalanced paranthesis
Go to the top of the page
 
+Quote Post
kblm
post Apr 11 2007, 12:44 PM
Post #29


HR 2
**

Group: Members
Posts: 13
Joined: 29-September 06
User's local time:
Jul 31 2010, 06:53 PM
Member No.: 14,128



QUOTE(chrishirst @ Apr 11 2007, 10:24 AM) *
it certainly can

simplest would be to use a regular expression,


Chris,

I'm getting the following error:
CODE
Microsoft VBScript compilation  error '800a03f9'

Expected 'Then'

/error.asp, line 126

if instr(request.servervariables("QUERY_STRING"), "testing_")) <> 0 then
--------------------------------------------------------------^



Any ideas?

-Kevin
Go to the top of the page
 
+Quote Post
chrishirst
post Apr 11 2007, 02:40 PM
Post #30


HR 9
Group Icon

Group: Moderator
Posts: 4,574
Joined: 13-August 03
User's local time:
Aug 1 2010, 12:53 AM
From: Blackpool UK
Member No.: 492



unbalanced paranthesis is the problem (IMG:style_emoticons/default/biggrin.gif)

there is an extra ")" that snuck in there

Go to the top of the page
 
+Quote Post

3 Pages V  < 1 2 3 >   
Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



This forum is sponsored by High Rankings, a Boston SEO Agency
- Lo-Fi Version Time is now: 31st July 2010 - 06:53 PM