开发者

Alternate solution for htaccess in ASP

I have a shared hosting account and don't have access to IIS server, so can not i开发者_运维知识库nstall ISAPI_Rewrite on server or any other rewrite solution.

Website language is in classic ASP and want to create rewrite rule, but I cannot use .htaccess file.

So is there any alternate way or I can use .htaccess?

Thanks for help.


If your hosting is Windows 2008 (IIS 7) then you can install Helicon Ape onto your shared account for .htaccess support.


If your hoster permits you to change the 404 custom error page in their control panel to an ASP script then there's a trick you can do that emulates a rewriting engine.

If you map your 404 custom error to a page such as /404.asp you can then parse the QUERY_STRING server variable. Here's a very simplistic skeleton you could start with:

<%
raw = Request.ServerVariables("QUERY_STRING")

' Extract URL
startPos = Instr(1, raw, ";",1) + 1
url = Mid(raw, startPos, Len(raw) - (startPos - 1))

' Assumes no wacky ports
startPos = Instr(1, url, ":80/",1)
If startPos = 0 Then 
  startPos = Instr(1, url, ":443/",1) + 4
Else
  startPos = startPos + 3
End If

' Get path/querystring
path = Mid(url, startPos, Len(url) - (startPos - 1))

' Now parse your path/querystring...your code goes here

Server.Transfer somePage
%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜