Rewrite rule
am 31.12.2006 12:06:22 von Mathieu Maes
Hello everybody
In apache I used a feature called a "Rewrite rule" inside a .htaccess
file to process the URL :
i.e. http://www/mypage.html => http://www/page.php?page=mypage
Now I'd like to do a similar action on a IIS server with ASP (not
..net)...
Can anyone tell me how you can do this ?
thanks in advance!
Mathew
Re: Rewrite rule
am 31.12.2006 13:35:12 von exjxw.hannivoort
Lupus wrote on 31 dec 2006 in microsoft.public.inetserver.asp.general:
> Hello everybody
>
> In apache I used a feature called a "Rewrite rule" inside a .htaccess
> file to process the URL :
> i.e. http://www/mypage.html => http://www/page.php?page=mypage
>
> Now I'd like to do a similar action on a IIS server with ASP (not
> .net)...
>
> Can anyone tell me how you can do this ?
Meseems you will have to explain what it does.
In general we do not use apache.
Possibly this is the effect you want:
========http://www/mypage.html ============
<% ' vbscript
response.redirect "/page2.php?page=mypage"
%>
===========================================
If you want to redirect from nonexisting pages,
I suggest from a specified [even nonexisting] directory,
you could write code in te dedicated 404.asp page
redirecting those calls and selecting the pagename as
querystring.
However, this can be better done as a server.transfer,
where the original virtual calling string
is available in a session variable.
[do not forget to clear the session variable
after extraction of the page name,
or do not use it elswhere in the session]
============= /404.asp ====================
<%
qstr = lcase(Request.ServerVariables("QUERY_STRING"))
if instr(qstr,":80/virtualdirectory/")>0 then
session("qstr")=qstr
server.transfer "/anydirectory/page.php"
end if
%>
......
This is our 404 page.
The page you want:
<%=qstr%>
does not exist.
==========================================
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: Rewrite rule
am 01.01.2007 03:14:58 von mmcginty
"Evertjan." wrote in message
news:Xns98AA8A363F77Beejj99@194.109.133.242...
> Lupus wrote on 31 dec 2006 in microsoft.public.inetserver.asp.general:
>
>> Hello everybody
>>
>> In apache I used a feature called a "Rewrite rule" inside a .htaccess
>> file to process the URL :
>> i.e. http://www/mypage.html => http://www/page.php?page=mypage
>>
>> Now I'd like to do a similar action on a IIS server with ASP (not
>> .net)...
>>
>> Can anyone tell me how you can do this ?
>
> Meseems you will have to explain what it does.
> In general we do not use apache.
>
> Possibly this is the effect you want:
>
> ========http://www/mypage.html ============
>
> <% ' vbscript
> response.redirect "/page2.php?page=mypage"
> %>
>
> ===========================================
What exactly would you expect this to do in an .HTML file? Unless you
mapped the .html extension to asp.dll, to process files with that extension
as server-side script, the correct answer would be "nothing".
-Mark
> If you want to redirect from nonexisting pages,
> I suggest from a specified [even nonexisting] directory,
> you could write code in te dedicated 404.asp page
> redirecting those calls and selecting the pagename as
> querystring.
>
> However, this can be better done as a server.transfer,
> where the original virtual calling string
> is available in a session variable.
> [do not forget to clear the session variable
> after extraction of the page name,
> or do not use it elswhere in the session]
>
> ============= /404.asp ====================
> <%
> qstr = lcase(Request.ServerVariables("QUERY_STRING"))
> if instr(qstr,":80/virtualdirectory/")>0 then
> session("qstr")=qstr
> server.transfer "/anydirectory/page.php"
> end if
> %>
>
> .....
> This is our 404 page.
> The page you want:
> <%=qstr%>
> does not exist.
>
> ==========================================
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
Re: Rewrite rule
am 01.01.2007 11:05:28 von exjxw.hannivoort
Mark McGinty wrote on 01 jan 2007 in
microsoft.public.inetserver.asp.general:
>> ========http://www/mypage.html ============
>>
>> <% ' vbscript
>> response.redirect "/page2.php?page=mypage"
>> %>
>>
>> ===========================================
>
> What exactly would you expect this to do in an .HTML file?
> Unless you
> mapped the .html extension to asp.dll, to process files with that
> extension as server-side script, the correct answer would be
> "nothing".
>
True. My mistake, read: http://www.??.??/mypage.asp
IIS can remap [about?] any extention to be read by the asp interpreter.
>> ============= /404.asp ====================
>> <%
>> qstr = lcase(Request.ServerVariables("QUERY_STRING"))
>> if instr(qstr,":80/virtualdir/")>0 then
>> session("qstr")=qstr
>> server.transfer "/anydirectory/page.php"
>> [..]
The .php, could be anything, I prefer page.asp
>> end if
>> %>
However, my real [in my view] answer was this use of 404.asp.
The extention of the nonexisitng [=virtual] pages does not matter here,
the asp interpereater is always "on".
The page.asp could be something like this:
[on my site, even Google sees this page as 110 different ones]
=========== /anydirectory/page.asp ================
.....
<% if instr(session("qstr"),"/virtualdir/xxx.html")>0 then %>
This is the content of xxx .............
<% elseif instr(session("qstr"),"/virtualdir/blah.qrs")>0 then %>
This is the content of blah .............
<% elseif instr(session("qstr"),"/virtualdir/otherext.asp")>0 then %>
This is the content of <%=session("qstr")%>:
..............
<% else %>
Page not found [404]
<%
session("qstr") = ""
response.end
end if
session("qstr") = ""
%>
General footer [except for not found 404] .........