Custom URL Rewriting in Classic ASP

2020-04-01 07:37发布

问题:

I have been trying to rewrite the URL in classic ASP. I am currently using IIS 7.5. I tried to use the URL Rewrite plugin which converts the following link:

http://blog.johnavis.com/blog/default.asp?id=19

into something like this:

blog.johnavis.com/19/

blog.johnavis.com/id/19/

blog.johnavis.com/blog/default/19

blog.johnavis.com/blog/default/id/19

I want to convert into something like this: http://blog.johnavis.com/blog/myblog/

Can that be achieved? Any help would be appreciated.

回答1:

Basically all the rewrite module does is to edit your web.config file. You're probably better off editing the file yourself. You'll find that it has created a section called rewrite, add the following rule

        <rewrite>
            <rules>
                <rule name="My Blog">
                    <match url="blog/myblog/" />
                    <action type="Rewrite" url="blog/default.asp?id=19" />
                </rule>

            </rules>
        </rewrite>


回答2:

You can achieve this by creating URL rewrite rule in IIS Manager by defining a pattern. Use the following links to learn about that.

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-video-walkthrough

Hope this helps...