URL friendly Classic ASP with Isapi Rewrite

Asked

Viewed 246 times

0

Good morning, you guys.

The point is I can access an address dominio.com/modulo/id/titulo and he rewrites to dominio.com/default.asp?link=artigo&id=123&titulo=teste, but my question is whether I can do the reverse process, ie access dominio.com/default.asp?link=artigo&id=123&titulo=teste and he change to dominio.com/modulo/id/titulo.

Codes:

ASP

<!DOCTYPE html><html lang="pt-br"><head><meta charset="utf-8"/><title>Teste Isapi Rewrite</title></head><body><p>Teste!<br>link: <%=request("link")%><br>id: <%=request("id")%><br>teste: <%=request("teste")%><br></p></body></html>

WEB.CONFIG

<?xml version="1.0" encoding="UTF-8"?>

<system.webServer>
    <rewrite>
        <rules>
            <rule name="artigo" stopProcessing="true">
                <match url="^artigo/?([a-zA-Z0-9_-]+)?/?([a-zA-Z0-9_-]+)?/?([a-zA-Z0-9_-]+)?$" />
                <conditions> 
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
                </conditions>
                <action type="Rewrite" url="default.asp?link={R:0}&amp;id={R:1}&amp;teste={R:2}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

Thanks in advance!

1 answer

0


Solved with the following rules:

<rule name="reverse" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{REQUEST_URI}" pattern="default.asp" />
        <add input="{QUERY_STRING}" pattern="link=(.*)\&amp;id=(.*)\&amp;titulo=(.*)" />
    </conditions>
    <action type="Redirect" url="http://{HTTP_HOST}/{C:1}/{C:2}/{C:3}" appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" enabled="true" stopProcessing="true">
    <match url="^([^/]+)/([^/]+)/([^/]+)/?$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="default.asp?link={R:1}&amp;id={R:2}&amp;titulo={R:3}" appendQueryString="false" />
</rule>

https://stackoverflow.com/questions/57760191/url-friendly-asp-classic-and-isapi-rewrite

Browser other questions tagged

You are not signed in. Login or sign up in order to post.