Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > URL rewriting with ASP

Reply
Thread Tools

URL rewriting with ASP

 
 
daddywhite
Guest
Posts: n/a
 
      07-28-2007
I need to rewrite a URL like:

FROM: /mypage.asp?my_id=78

TO: /contact-us

Where contact us is the name of that page stored ion a database.

I can easily use a ISAPI filter to change it to:

/page/78/contact-us

HOWEVER i do not want the "78" in the URL. The reason for this is that
site is already established under names like "/contact-us" as it was
done is .net somehow.

Anyway of doing this in ASP?

I had the idea of physically creating the folder "/contact-us" using
the FSO and thendropping in an index file which searched the database
for the ID based on the name of the page, then set a session based on
that ID and then did a server.transfer to the "mypage.asp" and changed
that page to look for the session rather than the querystring.

Just wondering if anyone has a neater way?

Regards and thanks for your time.

Dave.

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      07-29-2007
"daddywhite" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> I need to rewrite a URL like:
>
> FROM: /mypage.asp?my_id=78
>
> TO: /contact-us
>
> Where contact us is the name of that page stored ion a database.
>
> I can easily use a ISAPI filter to change it to:
>
> /page/78/contact-us
>
> HOWEVER i do not want the "78" in the URL. The reason for this is that
> site is already established under names like "/contact-us" as it was
> done is .net somehow.
>
> Anyway of doing this in ASP?
>
> I had the idea of physically creating the folder "/contact-us" using
> the FSO and thendropping in an index file which searched the database
> for the ID based on the name of the page, then set a session based on
> that ID and then did a server.transfer to the "mypage.asp" and changed
> that page to look for the session rather than the querystring.
>
> Just wondering if anyone has a neater way?
>
> Regards and thanks for your time.
>


Dave,

I'm finding it a little bit confusing to follow what effect you are really
after. It seems to be an unusual direction, normally one takes a
non-existant url such as /contact-us and re-writes it to a specific one like
/mypage.asp?my_id=78 for actual processing. What you seem to be asking for
is the other way round, is that correct?

You indicate that currently /contact-us doesn't physically exist. What do
you expect to happen when you attempt to re-write the URL to /custom-us?

If you need to pass on info to whatever processes the /custom-us URL such as
the user ID you can have your ISAPI filter add a custom header to the
request.

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
 
daddywhite
Guest
Posts: n/a
 
      07-29-2007
yes, "/contact-us" does not exist and I wish oit to re-write to the "/
mypage.asp?id=78"

The only way I have it done is using a ISAPI filter but that requires
that the id "78" or whatever is in the URL to be re-written

eg: "/78/contact-us"

HOWEVER i do not wish to have the "78" there - the reason for this is
that the website is already established and therefore the SEO links
are already looking at "/contact-us" - I want to keep this
functionality so as to not affect the SEO rankings. PLUS the client
wishes keep it this way.

The only way I have found is using custom 404 errors to extract the
"contact-us", look in the database for this title in order to find the
id of the page, then set a session equal to the ID then
server.transfer to the "mypage.asp"

This make sense?

 
Reply With Quote
 
toudidel
Guest
Posts: n/a
 
      07-29-2007
you can do it overwriting 404 http error

--
td
www.uddi.pl


 
Reply With Quote
 
daddywhite
Guest
Posts: n/a
 
      07-29-2007
anyone got a slightly more useful and indepth answer?

thanks in advance

regards
dave

 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      07-29-2007
"daddywhite" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> yes, "/contact-us" does not exist and I wish oit to re-write to the "/
> mypage.asp?id=78"
>
> The only way I have it done is using a ISAPI filter but that requires
> that the id "78" or whatever is in the URL to be re-written
>
> eg: "/78/contact-us"
>
> HOWEVER i do not wish to have the "78" there - the reason for this is
> that the website is already established and therefore the SEO links
> are already looking at "/contact-us" - I want to keep this
> functionality so as to not affect the SEO rankings. PLUS the client
> wishes keep it this way.
>
> The only way I have found is using custom 404 errors to extract the
> "contact-us", look in the database for this title in order to find the
> id of the page, then set a session equal to the ID then
> server.transfer to the "mypage.asp"
>
> This make sense?
>


It's getting closer but still a little muddy.

I take it that if the "78" in all this is some kind of user ID or some other
data which may vary.

In that case if you want the existing URL to remain simpy "/contact-us" then
where would the ID value be held? A cookie? Session variable? or something
else?

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
daddywhite
Guest
Posts: n/a
 
      07-29-2007
On 29 Jul, 16:00, "Anthony Jones" <(E-Mail Removed)> wrote:
> "daddywhite" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) oups.com...
>
>
>
>
>
> > yes, "/contact-us" does not exist and I wish oit to re-write to the "/
> > mypage.asp?id=78"

>
> > The only way I have it done is using a ISAPI filter but that requires
> > that the id "78" or whatever is in the URL to be re-written

>
> > eg: "/78/contact-us"

>
> > HOWEVER i do not wish to have the "78" there - the reason for this is
> > that the website is already established and therefore the SEO links
> > are already looking at "/contact-us" - I want to keep this
> > functionality so as to not affect the SEO rankings. PLUS the client
> > wishes keep it this way.

>
> > The only way I have found is using custom 404 errors to extract the
> > "contact-us", look in the database for this title in order to find the
> > id of the page, then set a session equal to the ID then
> > server.transfer to the "mypage.asp"

>
> > This make sense?

>
> It's getting closer but still a little muddy.
>
> I take it that if the "78" in all this is some kind of user ID or some other
> data which may vary.
>
> In that case if you want the existing URL to remain simpy "/contact-us" then
> where would the ID value be held? A cookie? Session variable? or something
> else?
>
> --
> Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
>
> - Show quoted text -


EXACLTY, that is the question I am asking. I assume a session
variable.

The 78 refers to the Id of the page held in the database.

I see lots of websites with /contact-us which are obviously database
driven - just wondering the best way to do this in ASP

see bbrail.com for example




 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      07-29-2007
daddywhite wrote:
> On 29 Jul, 16:00, "Anthony Jones" <(E-Mail Removed)> wrote:
>> "daddywhite" <(E-Mail Removed)> wrote in message
>>
>> news:(E-Mail Removed) oups.com...
>>
>>
>>
>>
>>
>>> yes, "/contact-us" does not exist and I wish oit to re-write to the
>>> "/ mypage.asp?id=78"

>>
>>> The only way I have it done is using a ISAPI filter but that
>>> requires that the id "78" or whatever is in the URL to be re-written

>>
>>> eg: "/78/contact-us"

>>
>>> HOWEVER i do not wish to have the "78" there - the reason for this
>>> is that the website is already established and therefore the SEO
>>> links
>>> are already looking at "/contact-us" - I want to keep this
>>> functionality so as to not affect the SEO rankings. PLUS the client
>>> wishes keep it this way.

>>
>>> The only way I have found is using custom 404 errors to extract the
>>> "contact-us", look in the database for this title in order to find
>>> the
>>> id of the page, then set a session equal to the ID then
>>> server.transfer to the "mypage.asp"

>>
>>> This make sense?

>>
>> It's getting closer but still a little muddy.
>>
>> I take it that if the "78" in all this is some kind of user ID or
>> some other data which may vary.
>>
>> In that case if you want the existing URL to remain simpy
>> "/contact-us" then where would the ID value be held? A cookie?
>> Session variable? or something else?
>>
>> --
>> Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
>>
>> - Show quoted text -

>
> EXACLTY, that is the question I am asking. I assume a session
> variable.
>
> The 78 refers to the Id of the page held in the database.
>


If the id is in a session variable, what is it doing in the url?

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      07-29-2007
"daddywhite" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> On 29 Jul, 16:00, "Anthony Jones" <(E-Mail Removed)> wrote:
> > "daddywhite" <(E-Mail Removed)> wrote in message
> >
> > news:(E-Mail Removed) oups.com...
> >
> >
> > > yes, "/contact-us" does not exist and I wish oit to re-write to the "/
> > > mypage.asp?id=78"

> >
> > > The only way I have it done is using a ISAPI filter but that requires
> > > that the id "78" or whatever is in the URL to be re-written

> >
> > > eg: "/78/contact-us"

> >
> > > HOWEVER i do not wish to have the "78" there - the reason for this is
> > > that the website is already established and therefore the SEO links
> > > are already looking at "/contact-us" - I want to keep this
> > > functionality so as to not affect the SEO rankings. PLUS the client
> > > wishes keep it this way.

> >
> > > The only way I have found is using custom 404 errors to extract the
> > > "contact-us", look in the database for this title in order to find the
> > > id of the page, then set a session equal to the ID then
> > > server.transfer to the "mypage.asp"

> >
> > > This make sense?

> >
> > It's getting closer but still a little muddy.
> >
> > I take it that if the "78" in all this is some kind of user ID or some

other
> > data which may vary.
> >
> > In that case if you want the existing URL to remain simpy "/contact-us"

then
> > where would the ID value be held? A cookie? Session variable? or

something
> > else?
> >
> > --
> > Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
> >
> > - Show quoted text -

>
> EXACLTY, that is the question I am asking. I assume a session
> variable.
>
> The 78 refers to the Id of the page held in the database.
>


Ok still trying to demystify your requirement. I think your in a situation
where depending on the context of the current user session a visit to
/contact-us is expected to generate different results. An ID is to be
associated with the users session that specifies that content. I doubt I
have that right but in case I do:-

Store the ID in the Session object, use the 404 kludge, test that
/content-us is being requested, server.transfer to mypage.asp and have
mypage.asp retrieve the value its interested in from the session object.

Alternatively get the ISAPI filter to re-write the url to mypage.asp which
can still retrieve the ID from the session object.

--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
daddywhite
Guest
Posts: n/a
 
      07-29-2007
On 29 Jul, 17:26, "Anthony Jones" <(E-Mail Removed)> wrote:
> "daddywhite" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ups.com...
>
>
>
>
>
> > On 29 Jul, 16:00, "Anthony Jones" <(E-Mail Removed)> wrote:
> > > "daddywhite" <(E-Mail Removed)> wrote in message

>
> > >news:(E-Mail Removed) roups.com...

>
> > > > yes, "/contact-us" does not exist and I wish oit to re-write to the "/
> > > > mypage.asp?id=78"

>
> > > > The only way I have it done is using a ISAPI filter but that requires
> > > > that the id "78" or whatever is in the URL to be re-written

>
> > > > eg: "/78/contact-us"

>
> > > > HOWEVER i do not wish to have the "78" there - the reason for this is
> > > > that the website is already established and therefore the SEO links
> > > > are already looking at "/contact-us" - I want to keep this
> > > > functionality so as to not affect the SEO rankings. PLUS the client
> > > > wishes keep it this way.

>
> > > > The only way I have found is using custom 404 errors to extract the
> > > > "contact-us", look in the database for this title in order to find the
> > > > id of the page, then set a session equal to the ID then
> > > > server.transfer to the "mypage.asp"

>
> > > > This make sense?

>
> > > It's getting closer but still a little muddy.

>
> > > I take it that if the "78" in all this is some kind of user ID or some

> other
> > > data which may vary.

>
> > > In that case if you want the existing URL to remain simpy "/contact-us"

> then
> > > where would the ID value be held? A cookie? Session variable? or

> something
> > > else?

>
> > > --
> > > Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -

>
> > > - Show quoted text -

>
> > EXACLTY, that is the question I am asking. I assume a session
> > variable.

>
> > The 78 refers to the Id of the page held in the database.

>
> Ok still trying to demystify your requirement. I think your in a situation
> where depending on the context of the current user session a visit to
> /contact-us is expected to generate different results. An ID is to be
> associated with the users session that specifies that content. I doubt I
> have that right but in case I do:-
>
> Store the ID in the Session object, use the 404 kludge, test that
> /content-us is being requested, server.transfer to mypage.asp and have
> mypage.asp retrieve the value its interested in from the session object.
>
> Alternatively get the ISAPI filter to re-write the url to mypage.asp which
> can still retrieve the ID from the session object.
>
> --
> Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
>
> - Show quoted text -


Thanks for your reply
===============================
> Store the ID in the Session object, use the 404 kludge, test that
> /content-us is being requested, server.transfer to mypage.asp and have
> mypage.asp retrieve the value its interested in from the session object.

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

This is exactly what I thought I would need to do.

I was wondering whether there was any other way - I know about the
ISAPI filter method but that would require the ID being in the URL
somewhere.I DO NOT want this to happen.

One way I figured was:

1) "/contact-us"
2) ISAPI rewrites this to "mypage.asp" passing "contact-us" as a
querystring
3) "mypage.asp" looks in database for "contact-us" and then displayed
the relevant page content
4) alternatively on the "mypage.asp" if the querystring returns
"*.asp" then server.transfer to that ASP page. (cos not all of the
websites pages are dynamic database driven)

Does this make sense as to what I am tring to do?

Unless I can use the ISAPI filter to only kick in when ".asp" is NOT
found in the URL of course.

Apologies if I am/was not making sense - its quite hard to explain
what I am trying to acheive.


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Rewriting in ASP.NET Toni ASP .Net 2 05-29-2008 09:28 AM
asp.net url rewriting thoeone ASP .Net 4 02-29-2008 01:06 PM
url rewriting with no extension in url =?Utf-8?B?cmFwaWRkYXRh?= ASP .Net 8 11-02-2006 01:48 PM
Actionless form for URL rewriting in ASP.NET V 2.0? Rocky Moore ASP .Net 0 09-14-2005 11:21 PM
url rewriting when the url contains parameters Gaurav Agarwal Java 2 01-31-2005 11:15 AM



Advertisments