Print Page | Close Window

simple rewrite url in web.config

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=31606
Printed Date: 28 March 2026 at 9:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: simple rewrite url in web.config
Posted By: fabrixnet
Subject: simple rewrite url in web.config
Date Posted: 22 March 2019 at 6:46pm
Hello,
I would like to rewrite url from http://www.website.com/index.asp?lang=en" rel="nofollow - www.website.com/index.asp?lang=en to http://www.www.website.com/en" rel="nofollow - www.www.website.com/en
In web.config I have inserted the code but it doesn't work, what's the right way?


        <rewrite>
            <rules>

              <!-- index -->
              <rule name="index 1">
                <match url="^index\.asp(.*)" ignoreCase="true" />
                <conditions logicalGrouping="MatchAll">
                  <add input="{QUERY_STRING}" pattern="^(.*)lang=(.*)" ignoreCase="true" />
                </conditions>
                <action type="Redirect" url="{C:2}/" appendQueryString="false" />
              </rule>

              <rule name="index 2" stopProcessing="true">
                <match url="^/(.*)" ignoreCase="true" />
                <action type="Rewrite" url="index.asp?lang={R:1}" appendQueryString="false" />
              </rule>

            </rules>
        </rewrite>



Replies:
Posted By: WebWiz-Bruce
Date Posted: 25 March 2019 at 4:43pm
Is the first rule redirecting to http://www.website.com/en" rel="nofollow - www.website.com/en   ?

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: fabrixnet
Date Posted: 25 March 2019 at 5:21pm
Yes, http://www.website.com/index.asp?lang=en" rel="nofollow - www.website.com/index.asp?lang=en redirecting to http://www.website.com/en" rel="nofollow - www.website.com/en


Posted By: WebWiz-Bruce
Date Posted: 26 March 2019 at 8:23am
The first rule that does the redirect is working then and it is the second rule "index 2" that detects the new URL and tells the web server which file to use to process that you need to look at.

I suspect that the following part of "index 2" is not spotting your redirected URL;

<match url="^/(.*)" ignoreCase="true" />

The web server may or may not receive the request as  http://www.website.com/en/" rel="nofollow - www.website.com/en/

You could try something like below, but I am sure that is a better way to do this;

<match url="(.*)/" ignoreCase="true" />


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: fabrixnet
Date Posted: 27 March 2019 at 11:04am
Your suggestion works by inserting the web.config on internal folders, example:
http://www.website.com/news/en/" rel="nofollow - www.website.com/news/en/
This is already a good step for me
Thank you very much!

Unfortunately it don't work with http://www.website.com/en/" rel="nofollow - www.website.com/en/
bye



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net