Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - simple rewrite url in web.config
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

simple rewrite url in web.config

 Post Reply Post Reply
Author
fabrixnet View Drop Down
Groupie
Groupie
Avatar

Joined: 19 June 2002
Location: Italy
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote fabrixnet Quote  Post ReplyReply Direct Link To This Post Topic: simple rewrite url in web.config
    Posted: 22 March 2019 at 6:46pm
Hello,
I would like to rewrite url from www.website.com/index.asp?lang=en to 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>
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Online
Points: 9791
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2019 at 4:43pm
Is the first rule redirecting to www.website.com/en  ?
Back to Top
fabrixnet View Drop Down
Groupie
Groupie
Avatar

Joined: 19 June 2002
Location: Italy
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote fabrixnet Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2019 at 5:21pm
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Online
Points: 9791
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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 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" />
Back to Top
fabrixnet View Drop Down
Groupie
Groupie
Avatar

Joined: 19 June 2002
Location: Italy
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote fabrixnet Quote  Post ReplyReply Direct Link To This Post Posted: 27 March 2019 at 11:04am
Your suggestion works by inserting the web.config on internal folders, example:
www.website.com/news/en/
This is already a good step for me
Thank you very much!

Unfortunately it don't work with www.website.com/en/
bye
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.