Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Closed Thread
301 Redirect Question
Old 05-26-2010, 03:21 PM 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
I am trying to 301 redirect a page when a query string is present. Why? Because some websites are linking to the page with query strings and it is coming up a duplicate content. So I want ...somepage.asp?xxx=yyy&zzz=123 to 301 to somepage.asp

Any easy solutions?

Thanks...I just can't THINK today!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
 
Register now for full access!
Old 05-26-2010, 03:24 PM Re: 301 Redirect Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Does it need to carry the querystring values with it?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 05-26-2010, 04:40 PM Re: 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Does it need to carry the querystring values with it?
No. The script uses POST not GET, yet people link to it with a query string.

I used this code on a page I have that had at one time been used for affiliates that worked, but doesn't for this page???
<%
If Request.QueryString("Affid") Then
Response.Buffer = True
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.searchbliss.com/generators.asp"
Response.Flush
Response.End
End If
%>
The query string has rank=www.someidiotsdomain.com, so when I replace "Affid" with "rank" and redirect to ...com/rank.asp I get a 404 when I use the query string, and NOT when I don't???
Thanks Chris!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by kline11; 05-26-2010 at 04:41 PM..
kline11 is offline
View Public Profile
 
Old 05-26-2010, 06:04 PM Re: 301 Redirect Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
If Request.QueryString("rank") <> "" Then

should work Ok

Quote:
The query string has rank=www.someidiotsdomain.com, so when I replace "Affid" with "rank" and redirect to ...com/rank.asp I get a 404 when I use the query string, and NOT when I don't
Does the script on the page try to process the request collections rather than just request.form collection only?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 05-26-2010, 06:59 PM Re: 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
Quote:
Originally Posted by chrishirst View Post
If Request.QueryString("rank") <> "" Then

should work Ok


Does the script on the page try to process the request collections rather than just request.form collection only?
request.form only.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
Old 05-27-2010, 12:10 PM Re: 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
Hey Chris,
I've been racking my brain on this and all fails.

The page that works has the following at the top:
<%@ LANGUAGE="VBScript" %>
<%
If Request.QueryString("rank") Then
Response.Buffer = True
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.searchbliss.com/rank.asp"
Response.Flush
Response.End
End If
%>

The page that doesn't has this:

<%@ LANGUAGE="VBScript" %>
<%
Option Explicit
Response.Buffer = true
Dim blnSubmitted
If Request.Form("AC") <> "" Then
blnSubmitted = true
End If
If Request.QueryString("rank") Then
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.searchbliss.com/rank.asp"
Response.Flush
Response.End
End If
%>

If there is NO query string all is OK, but if one is present, I get a 404 error rather then the redirect???
Thanks.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
Old 05-27-2010, 01:36 PM Re: 301 Redirect Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The error is NOT a 404 but a 500 error

from WebBug;
Quote:
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Length: 19773
Content-Type: text/html
Server: Microsoft-IIS/7.0
Only problem is: Microsoft in their "wisdom" have blocked error messages from being sent to the browser in IIS 7, which is a real PITA to debug anything unless you have direct access to the server!!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2010, 01:54 PM Re: 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
Quote:
Originally Posted by chrishirst View Post
The error is NOT a 404 but a 500 error

from WebBug;


Only problem is: Microsoft in their "wisdom" have blocked error messages from being sent to the browser in IIS 7, which is a real PITA to debug anything unless you have direct access to the server!!
What's odd is I see 500 errors genarically (set up by the host), but this error points to my custom 404 page set in the web.config file for both 404 and 403 errors???
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
Old 05-27-2010, 02:06 PM Re: 301 Redirect Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
web.config only affects .net script errors "classic" ASP error handlers are set up separately in IIS management.

Do you have RDP or TS access to the server (or Plesk maybe) to make changes to the custom error pages?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2010, 02:51 PM Re: 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
Quote:
Originally Posted by chrishirst View Post
web.config only affects .net script errors "classic" ASP error handlers are set up separately in IIS management.

Do you have RDP or TS access to the server (or Plesk maybe) to make changes to the custom error pages?
No I don't have access Chris...why won't this simple 301 work on this page, but work on others! Sorry, had to vent that.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
Old 05-27-2010, 03:12 PM Re: 301 Redirect Question
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,336
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Ok set up test pages on my local server (IIS7 on Win7 Ultimate) the error is a type mismatch

This
Code:
If Request.QueryString("rank")  Then
should be
Code:
If Request.QueryString("rank") <> "" Then
"If Request.QueryString("rank") Then" would expect "rank" to be a boolean value NOT a string.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 05-27-2010 at 03:13 PM..
chrishirst is online now
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2010, 03:20 PM Re: 301 Redirect Question
kline11's Avatar
SearchBliss Web Tools

Posts: 1,782
Name: John
Location: USA
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Ok set up test pages on my local server (IIS7 on Win7 Ultimate) the error is a type mismatch

This
Code:
If Request.QueryString("rank")  Then
should be
Code:
If Request.QueryString("rank") <> "" Then
"If Request.QueryString("rank") Then" would expect "rank" to be a boolean value NOT a string.
Thanks Chris! It works perfectly. I tried this before to no avail, then realized this time I hadn't cleared the cache, and bingo...it works! I changed this on the other page as well (why the other worked there is beyond me) but I wanted it correct.

Hava a beer on me!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
View Public Profile
 
Closed Thread     « Reply to 301 Redirect Question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.72697 seconds with 12 queries