Get page name without folder details

  • Thread starter Colin Steademan
  • Start date
C

Colin Steademan

Is there a method of returning the name of the current URL, without any of the path details? I am currently using request.serverVariables("url"), but this returns the name of the page and its path. This is forces me to use the following IF statement to get my page to work correctly

<
If request.serverVariables("url") = "/pp/DEV/messages.asp" Then ..
%

This works fine. But since the URL is hard-coded, when I move my development pages to live I am forced to go in and change the script (and others) as follows

<
If request.serverVariables("url") = "/pp/LIVE/messages.asp" Then ..
%

I've looked at the other serverVariables available but none seem to just return the name of the page. Can anyone suggest a remedy for this

TIA

Coli
 
A

Alex Goodey

If Right(request.serverVariables("url"),
Len(request.serverVariables("url"))-InStrRev(request.serverVariables("url"),
"/")) = "messages.asp" then

Colin Steademan said:
Is there a method of returning the name of the current URL, without any of
the path details? I am currently using request.serverVariables("url"), but
this returns the name of the page and its path. This is forces me to use
the following IF statement to get my page to work correctly :
<%
If request.serverVariables("url") = "/pp/DEV/messages.asp" Then ...
%>

This works fine. But since the URL is hard-coded, when I move my
development pages to live I am forced to go in and change the script (and
others) as follows:
<%
If request.serverVariables("url") = "/pp/LIVE/messages.asp" Then ...
%>

I've looked at the other serverVariables available but none seem to just
return the name of the page. Can anyone suggest a remedy for this?
 
C

Colin Steadman

----- Alex Goodey wrote: -----

If Right(request.serverVariables("url"),
Len(request.serverVariables("url"))-InStrRev(request.serverVariables("url"),
"/")) = "messages.asp" then


Thankyou!
 
E

Evertjan.

=?Utf-8?B?Q29saW4gU3RlYWRlbWFu?= wrote on 03 feb 2004 in
microsoft.public.inetserver.asp.general:
<%
If request.serverVariables("url") = "/pp/LIVE/messages.asp" Then ...
%>

I've looked at the other serverVariables available but none seem to
just return the name of the page. Can anyone suggest a remedy for
this?

Think the other way around and test for:


If InStr(request.serverVariables("url"),"/messages.asp")>0 Then
 
C

Colin Steadman

<%
Think the other way around and test for:


If InStr(request.serverVariables("url"),"/messages.asp")>0 Then



Rats! That is a nice elegant solution. I'm disappointed I didn't
think of it myself, I really could and should have!

Thankyou.

Colin
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top