Successful way to Rewriting URLs with ASP?

T

Toni

Does anyone have a recommended method of rewriting URLs with classic ASP?

For example, if the browser shows the Friendly URL
www.mydomain.com/blue_widget

my app will show the following Content Page
www.mydomain.com/item.asp?id=32&type=d&color=blue

Right now, I'm experimenting with having my error 404 file do the redirect. But it's not
as clean as I'd like - if I do a Server.Transfer or Server.Execute to the content page
(the query strings are passed as session variables), the PATH_INFO shows that the URL is
my error 404 file, which messes up my SmarterStats site statistics (BTW, "Smarter"Stats
is actually pretty dumb).

If my error 404 file performs a Response.Redirect, the address bar sometimes shows the
Content Page URL instead of the Friendly URL, defeating the purpose.

Before deciding to spend the time, energy, and effort to move to ASP.NET 2.0, can anyone
tell me if you've successfully implemented a rewriting URL method that makes you happy?
Can the ASP.NET web.config file be made to work in this to successfully rewrite URLs?

Thanks!!!

Toni
 
T

Toni

Looks nice. But because I'm on a shared server, I'd like to exhaust all other solutions
before I install a server component.


...
 
A

Anthony Jones

Toni said:
Looks nice. But because I'm on a shared server, I'd like to exhaust all
other solutions
before I install a server component.

Then consider other solutions exhausted. The best you can do when all
you've got to play with is native ASP is the 404 hack.
 
D

daddywhite

Possible other way, but a bit shit, would to PHYSICALLY create a
folder called:"blue_widget". In that have an index.asp page which
defines any variables required and then does a server.execute on the
dynamic page:

############ index.asp in blue_widget folder ##########

Session("pageID") = 67
Server.Execute "displaypage.asp"

################################################

Obviously you would have to have display page use the session pageid
rather than a querystring.

Essentially this is very similar to the 404 hack but not quite as
dynamic so assume you wouldnt want to use this!! Just a thought
though.
 
V

Vicent Lauv

Hi Toni

I have new to Asp Developer however, i came across as the same your problem.
You would like your page. at www.mydomain.com/blue_widget. It is very simple
way to use your 404 Customer Error Code.

for example: if your site www.domain.com/holidays/trip-for-active-osaka.asp

you probablely can have www.domain.com/Trip_for_Active_Osaka

My 404.asp

<%
Dim strURL
Dim strBolum
Dim strSQL

Set strURL = Request.ServerVariables("QUERY_STRING")
strBolum = Split(strURL1,"/")

If strBolum("3") = "Trip_for_Active_Osaka" Then
Server.Execute("holidays/trip-for-active-osaka.asp")

End If

%>

i alraedy implemented this method mostly on www.cambodia-tourism.org
If you need help. You can contact me at Cambodia Tourism Site

Teachnology Change the World.
 
E

Evertjan.

=?Utf-8?B?VmljZW50IExhdXY=?= wrote on 21 jan 2009 in
microsoft.public.inetserver.asp.general:

[please always quote on usenet, this is not email]
I have new to Asp Developer however,

Sometimes I have new too.
i came across as the same your problem.
You would like your page. at www.mydomain.com/blue_widget. It is very
simple way to use your 404 Customer Error Code.

for example: if your site
www.domain.com/holidays/trip-for-active-osaka.asp

you probablely can have www.domain.com/Trip_for_Active_Osaka

My 404.asp

<%
Dim strURL
Dim strBolum
Dim strSQL

Why "Dim"?

It does not hurt, but in a short piece of asp it is superfluous
Set strURL = Request.ServerVariables("QUERY_STRING")

Why "Set"?

This is wrong,
as you just assigne a value to a variable.
Set is for objects.
strBolum = Split(strURL1,"/")
If strBolum("3") = "Trip_for_Active_Osaka" Then
Server.Execute("holidays/trip-for-active-osaka.asp")

Why "Server.Execute"?

Use "server.transfer"

because you do not want to come back to 404.asp, meseems
End If

%>

i alraedy implemented this method mostly on www.cambodia-tourism.org


If you need help. You can contact me at Cambodia Tourism Site

It is good to have new experts going such length,
but this is usenet. ;-)
 
A

Agile Consulting

Vicent said:
Hi Toni

I have new to Asp Developer however, i came across as the same your problem.
You would like your page. at www.mydomain.com/blue_widget. It is very simple
way to use your 404 Customer Error Code.

for example: if your site www.domain.com/holidays/trip-for-active-osaka.asp

you probablely can have www.domain.com/Trip_for_Active_Osaka

My 404.asp

<%
Dim strURL
Dim strBolum
Dim strSQL

Set strURL = Request.ServerVariables("QUERY_STRING")
strBolum = Split(strURL1,"/")

If strBolum("3") = "Trip_for_Active_Osaka" Then
Server.Execute("holidays/trip-for-active-osaka.asp")

End If

%>

i alraedy implemented this method mostly on www.cambodia-tourism.org
If you need help. You can contact me at Cambodia Tourism Site

Teachnology Change the World.
 

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

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top