About Rewrite rule query stringRSS

14 replies

Last post May 17, 2019 10:50 AM by sierratec

  • About Rewrite rule query string

    May 14, 2019 11:22 AM|sierratec|LINK

    Hi,

    We have configured Feedback module in Moodle

    The url will be https://www.xxxx.com/moodle/mod/feedback/view.php?id=41

    How can make this into 

    https://www.xxxx.com/moodle/mod/feedback/view/41 

    or

    https://www.xxxx.com/moodle/41

    We would like to do this only for view.php

    Please suggest

    Thanks

  • Re: About Rewrite rule query string

    May 15, 2019 02:57 AM|Able|LINK

    Hi sieratec,

    According to your description, if you want to get the value of querstring in urlrewrite , you should add a condition to it.Here is the rule , you could add it in web.config file, I hope it could help you.

     <rule name="rule1" stopProcessing="true">
                        <match url="^moodle/mod/feedback/view.php$" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{QUERY_STRING}" pattern="id=(.*)" />
                        </conditions>
                        <action type="Redirect" url="https://www.xxx.com/moodle/{C:1}" appendQueryString="false" />
                    </rule>

    Best Regards

    Able

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 15, 2019 10:42 AM|sierratec|LINK

    Hi,

    Thanks. But this is not working.

  • Re: About Rewrite rule query string

    May 16, 2019 07:38 AM|Able|LINK

    Hi,sierratec

    I had tested the rule, you could see as below:

     

    So,I suggest that you could check whether it exists any other rewrite rules in your rewrite module?Else I suggest  you could use FRT to track the URl request. Here is the link, I hope it could help you.

    https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis

    Best Regards

    Able

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 16, 2019 08:16 AM|sierratec|LINK

    Hi,

    Thanks for your support.

    This is working and redirecting.

    If I change action as 'Rewrite' this is not working. Could you please suggest.

  • Re: About Rewrite rule query string

    May 17, 2019 01:44 AM|Able|LINK

    Hi sierratec,

    According to your description, the difference between rewrite and redirect is that url rewrite will not change url, it's a jump inside the server. Url redirect will change the url which shows in the browser.You could know the detail as below, I hope it could help you.

    https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

    Best Regards

    Able 

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 17, 2019 05:57 AM|sierratec|LINK

    Hi,

    Thanks for your support

    I checked the link

    Actually I want to do the rewrite

    from

    https://www.xxx.com/Moodle/mod/feedback/view/41

    to

    https://www.xxx.com/Moodle/mod/feedback/view.php?id=41

    So I am trying as below but this is not working.

    <rule name="Rewrite to view.php">
    <match url="^Moodle/mod/feedback/view/([0-9]+)" />
    <action type="Rewrite" url="https://www.xxx.com/Moodle/mod/feedback/view.php?id={R:1}" />
    </rule>

    Could you please suggest is there any error

  • Re: About Rewrite rule query string

    May 17, 2019 06:05 AM|Able|LINK

    Hi sierratec,

    I have tested it on my side. There is no problem, you could rewrite to correct url as you want.

    Best Regards

    Able

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 17, 2019 06:37 AM|sierratec|LINK

    Hi Able

    Thanks for your reply

    I tried that but that is not working. So I tried as below. This is also didn't worked. Shows 404 error

    <rule name="Rewrite to view.php">
    <match url="https://www.xxxx.com/Survey/mod/feedback/view/([0-9]+)" />
    <action type="Rewrite" url="https://www.xxx.com/Survey/mod/feedback/view.php?id={R:1}" />
    </rule>

    I tested this as below in the hosting serer and there I couldn't find any issues

    Could you please suggest. Thanks

  • Re: About Rewrite rule query string

    May 17, 2019 06:54 AM|Able|LINK

    Hi sierratec,

    You could see that A url is composed of the following parts:HTTP(s)://{HTTP_HOST}/path/querstring.

    Then in url rewrite  <match url:> tag is created for getting path of the url and {HTTP_host } and querstring is in condition.

    Now in you situation,I think your first rule is right, you could see my page as below ,its  request url is what you want 

    So, I suggest that you could try below ways:

    1.make sure that you have only one rewrite rule is enabled, because it will do all rules from up to down.

    2.you could directly enter  https://www.xxx.com/Survey/mod/feedback/view.php?id=41 to see whether it could show well.

    3.Use Failed Request Tracing , this module could track the url request and see what happened .Here is the link,

    https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis

    4.Could you show me the details of error page? It will help me see error clearly.I trust your first rule is right. 

    Best Regards

    Able

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 17, 2019 07:04 AM|sierratec|LINK

    Hi Able,

    I have changed to first one

    These are the urls

    https://www.xxx.com/Survey/mod/feedback/view/41 - This shows 404

    https://www.xxx.com/Survey/mod/feedback/view.php?id=41 - This is working

    Thanks

  • Re: About Rewrite rule query string

    May 17, 2019 07:20 AM|Able|LINK

    Hi sierratec,

    I think it will work , oh, don't forget to use Ctrl +H to clear the cache in browser, I think it may be the reason.

     <rules>
                   <rule name="Rewrite to view.php">
    <match url="^Survey/mod/feedback/view/([0-9]+)" />
    <action type="Rewrite" url="https://www.sierratec.com/Survey/mod/feedback/view.php?id=41" />
    </rule>
                </rules>

    Best Regards

    Able

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 17, 2019 07:43 AM|sierratec|LINK

    Hi Able,

    Thanks for your support

    I tried after clearing cache also. But doesn't work

    Actually we are using WordPress for www.xxx.com

    Inside this we created a folder Survey and here we are using Moodle

    I have placed the web.config file in the root of www.xxx.com. Hope this is correct. Please suggest

  • Re: About Rewrite rule query string

    May 17, 2019 08:10 AM|Able|LINK

    Hi sierratec

    So I think it is not problem with IIS , I suggest that you could post your thread to WordPress forums.Here is the link ,I hope it could help you.

    https://wordpress.org/support/forums/

    Best Regards

    Able

    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: About Rewrite rule query string

    May 17, 2019 10:50 AM|sierratec|LINK

    Hi Able,

    Thanks for your support

    I will post in WP forum and get back