custom 404 page works in IE but not firefox

C

c676228

Hi all,

A couple of months ago. I posted a thread and asked for help for redirect
all our site *.htm pages to *.asp pages because of our site upgrade almost
all *.htm to *.asp.
So some community members suggested use custom error page and redirect the
page to the same file but different ext. *.asp and it works fine in IE. But
when we tested in firefox today. it is not working. I wonder why? It is
because firefox return different format qstr? can you give me some clue. How
can I display the qstr in broswer in order to investigate it?
here is the code:

<% ' vbs
qstr = Request.ServerVariables("QUERY_STRING")

If instr(lcase(qstr),".htm")>0 then
on error resume next
x = replace(qstr, "404;http://www.mydomain.com:80","")
'404;http://www.mydomain.com:80
x = replace(x,".htm",".asp")

'server.transfer x
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
'Response.Redirect x

on error resume next
Response.Redirect "http://www.mydomain.com/404Page.htm"
on error goto 0
Else
on error resume next
Response.Redirect "http://www.mydomain.com/404Page.htm"
End if
%>
 
S

Steven Cheng [MSFT]

Hi Betty,

In the script code you posted:

============
on error resume next
x = replace(qstr, "404;http://www.mydomain.com:80","")
'404;http://www.mydomain.com:80
x = replace(x,".htm",".asp")

'server.transfer x
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
'Response.Redirect x

on error resume next
Response.Redirect "http://www.mydomain.com/404Page.htm"
on error goto 0
==============

I think as long as you add the code to set response status(to 301) and the
new location, you can end the response. However, you still called another
Response.Redirect, is this your original code logic? Or is the following
code is necessary?

============
x = replace(qstr, "404;http://www.mydomain.com:80","")

x = replace(x,".htm",".asp")

Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
============

I've tested in my local box with Firefox browser, seem it can correctly
perform the redirection.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.


This posting is provided "AS IS" with no warranties, and confers no rights.






--------------------
 
E

Evertjan.

Steven Cheng [MSFT] wrote on 03 apr 2008 in
microsoft.public.inetserver.asp.general:
============
x = replace(qstr, "404;http://www.mydomain.com:80","")
x = replace(x,".htm",".asp")
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
============

But what would happen, Steven,
if I requested a nonexisting page?

An infinite loop? No nornmal 404 warning?

Try this:
[Nonexisting .asp versions wil be flagged,
in the second redirect to the 404.asp]

============

if lcase(right(qstr,4) = ".htm" then
x = replace(qstr, "404;http://www.mydomain.com:80","")
x = replace(x,".htm",".asp")
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
Response.End
end if
%>
This is the 404 page.
<br>
We are so sorry for you.
<br>
The requested page <%=qstr%> does not exist.

============

Even then the acting on the default file of the root
and other directories should be considered and changed.
 
C

c676228

thanks Evertjan and Steven.
I got it. It seems that on error resume next really messed up something.
that's really a big from you guys and because of my predefined launch day
tomorrow.

:=) thanks thanks.
--
Betty


Evertjan. said:
Steven Cheng [MSFT] wrote on 03 apr 2008 in
microsoft.public.inetserver.asp.general:
============
x = replace(qstr, "404;http://www.mydomain.com:80","")
x = replace(x,".htm",".asp")
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
============

But what would happen, Steven,
if I requested a nonexisting page?

An infinite loop? No nornmal 404 warning?

Try this:
[Nonexisting .asp versions wil be flagged,
in the second redirect to the 404.asp]

============

if lcase(right(qstr,4) = ".htm" then
x = replace(qstr, "404;http://www.mydomain.com:80","")
x = replace(x,".htm",".asp")
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
Response.End
end if
%>
This is the 404 page.
<br>
We are so sorry for you.
<br>
The requested page <%=qstr%> does not exist.

============

Even then the acting on the default file of the root
and other directories should be considered and changed.
 
S

Steven Cheng [MSFT]

Hi Betty,

Really glad that it works for you.

Have a nice launch day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: =?Utf-8?B?YzY3NjIyOA==?= <[email protected]>
References: <[email protected]>
Subject: RE: custom 404 page works in IE but not firefox
Date: Thu, 3 Apr 2008 22:49:00 -0700
thanks Evertjan and Steven.
I got it. It seems that on error resume next really messed up something.
that's really a big from you guys and because of my predefined launch day
tomorrow.

:=) thanks thanks.
--
Betty


Evertjan. said:
Steven Cheng [MSFT] wrote on 03 apr 2008 in
microsoft.public.inetserver.asp.general:
============
x = replace(qstr, "404;http://www.mydomain.com:80","")
x = replace(x,".htm",".asp")
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
============

But what would happen, Steven,
if I requested a nonexisting page?

An infinite loop? No nornmal 404 warning?

Try this:
[Nonexisting .asp versions wil be flagged,
in the second redirect to the 404.asp]

============

if lcase(right(qstr,4) = ".htm" then
x = replace(qstr, "404;http://www.mydomain.com:80","")
x = replace(x,".htm",".asp")
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", x
Response.End
end if
%>
This is the 404 page.
<br>
We are so sorry for you.
<br>
The requested page <%=qstr%> does not exist.

============

Even then the acting on the default file of the root
and other directories should be considered and changed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top