tag:blogger.com,1999:blog-2285278671879033267.post2863806702145241048..comments2023-10-30T15:07:43.671+00:00Comments on Atlantic Breeze: Using IIS URL RewriteSean Kearonhttp://www.blogger.com/profile/13745810241561834202noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-2285278671879033267.post-65590427409150439552021-03-02T11:44:45.337+00:002021-03-02T11:44:45.337+00:00I had the same question about reordering and it lo...I had the same question about reordering and it looks like there is some basic facility to do that.<br /><br />When creating the rule you can use -AtIndex 0, -AtIndex 1, etc.. Specifying the index does require you to have a concept of how many rules you'll be using since you cannot have only 1 rule in existence and then set the index to 2. But a handy trick with AtIndex 0 is that you can guarantee that if you are adding a rule later down the road that it can jump to being your first rule. This won't be applicable for everyone but I was looking for the same question and stumbled on here.<br /><br />Example: Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site' -filter "system.webServer/rewrite/rules" -AtIndex 1 -name "." -value @{name='YourRuleName';stopProcessing='True'}Halcy0nnoreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-69310751365819889692020-08-14T11:19:14.852+01:002020-08-14T11:19:14.852+01:00I think you would need to remove the sections you ...I think you would need to remove the sections you wanted to change using Remove-WebConfigurationProperty and then add then back in the order you wanted them.Sean Kearonhttps://www.blogger.com/profile/13745810241561834202noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-85327249349718469022020-08-14T11:11:11.288+01:002020-08-14T11:11:11.288+01:00How can I update the rules order with Powershell ?...How can I update the rules order with Powershell ?Anonymoushttps://www.blogger.com/profile/10757518729792322426noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-9652744482677866012015-03-24T15:20:39.776+00:002015-03-24T15:20:39.776+00:00Hi Sean,
We now already have all our rewrite rule...Hi Sean,<br /><br />We now already have all our rewrite rules listed globally, so that would be a bit confusing.<br /><br />I found out that this works for me:<br /><br />Add-WebConfigurationProperty -PSPath "IIS:" -Filter "/system.webServer/rewrite/globalRules" -Name "." -Value @{ name = $name }<br /><br />Thanks for your suggestion anyway,KPhttps://www.blogger.com/profile/14667058300036006561noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-38907399832643501152015-03-16T10:39:50.436+00:002015-03-16T10:39:50.436+00:00Hi KP
When you add a rule at the server level, it...Hi KP<br /><br />When you add a rule at the server level, it will show up in <i>all</i> sites.<br /><br />To check that, add another site and you should also see the rule in there.<br /><br />It is worth noting that it is possible for a site to override/disable a rule that is applied at the server level. Very useful if you ever need that!<br /><br />Cheers<br /><br />SeanSean Kearonhttps://www.blogger.com/profile/13745810241561834202noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-57501971275833566962015-03-16T09:30:02.229+00:002015-03-16T09:30:02.229+00:00Hi Sean,
Thanks for your suggestion. Unfortunatel...Hi Sean,<br /><br />Thanks for your suggestion. Unfortunately using -pspath 'iis:' still adds the rule to the default website.<br /><br />When I check the applicationHost.config the rule is added to the rules and not to globalRules:<br /><br /><rewrite><br /> <globalRules><br /> </globalRules><br /> <rules><br /> <rule name="Rule 1" stopProcessing="true" /><br /> </rules><br /></rewrite><br /><br />Any other suggestion?KPhttps://www.blogger.com/profile/14667058300036006561noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-23208680344159105142015-03-14T09:55:01.457+00:002015-03-14T09:55:01.457+00:00Hi KP
Try using -pspath 'iis:.
Cheers
SeanHi KP<br /><br />Try using <i>-pspath 'iis:</i>.<br /><br />Cheers<br /><br />Sean<br /><br /> Sean Kearonhttps://www.blogger.com/profile/13745810241561834202noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-51673220943509352932015-03-13T17:35:43.540+00:002015-03-13T17:35:43.540+00:00Hi,
I want to add a rewrite rule at server / root...Hi,<br /><br />I want to add a rewrite rule at server / root level, how can I do that?<br /><br />For the default website it is:<br />-pspath 'IIS:\Sites\Default Web Site\'<br /><br />but what should the -pspath be to apply a rule globally?<br /><br />Thanks!KPhttps://www.blogger.com/profile/14667058300036006561noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-30427423028802258502015-01-17T19:28:36.752+00:002015-01-17T19:28:36.752+00:00very perfect tutorial thanks a lot..very perfect tutorial thanks a lot..Hp Android dan Paket Internethttp://www.oshpandroid.comnoreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-59186276049027694462015-01-16T15:26:29.889+00:002015-01-16T15:26:29.889+00:00Hello Sean,
It worked Thanks !!Hello Sean,<br /><br />It worked Thanks !!Anonymoushttps://www.blogger.com/profile/02522579788841698529noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-55715172865347042422015-01-15T08:18:05.779+00:002015-01-15T08:18:05.779+00:00Hi Abhishek
PowerShell only expands variables in ...Hi Abhishek<br /><br />PowerShell only expands variables in strings that are enclosed in double quotes. Changing the string to use double quotes and then using the backtick character to escape the enclosed quotation marks will do what you need. For example:<br /><br /><br />$ruleName = 'Rule 1'<br />Add-WebConfigurationProperty `<br /> -pspath 'IIS:\Sites\Default Web Site\simple-rewrite' `<br /> -filter '/system.webserver/rewrite/rules' `<br /> -name "." `<br /> -value @{name=$ruleName; patternSyntax='ECMAScript'; stopProcessing='True'}<br /><br />Set-WebConfigurationProperty `<br /> -pspath 'IIS:\Sites\Default Web Site\simple-rewrite' `<br /> -filter "/system.webserver/rewrite/rules/rule[@name=`"$ruleName`"]/match" `<br /> -name url `<br /> -value '1.html'Sean Kearonhttps://www.blogger.com/profile/13745810241561834202noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-85395011338388062682015-01-14T23:17:45.625+00:002015-01-14T23:17:45.625+00:00Hello,
Add-WebConfigurationProperty takes the val...Hello,<br /><br />Add-WebConfigurationProperty takes the value <br /><br />But for Set-WebConfigurationProperty<br />gives error whether we write in doublequotes or without quoteAnonymoushttps://www.blogger.com/profile/02522579788841698529noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-49613455419994450712015-01-14T22:53:19.482+00:002015-01-14T22:53:19.482+00:00Hi Abhishek
If you are starting out with somethin...Hi Abhishek<br /><br />If you are starting out with something like this:<br /><br />Add-WebConfigurationProperty `<br /> -pspath 'IIS:\Sites\Default Web Site\simple-rewrite' `<br /> -filter '/system.webserver/rewrite/rules' `<br /> -name "." `<br /> -value @{name='Rule 1'; patternSyntax='ECMAScript'; stopProcessing='True'}<br /><br />Then you can use something like the following to set the name using a variable:<br /><br />$ruleName = 'Rule 1'<br />Add-WebConfigurationProperty `<br /> -pspath 'IIS:\Sites\Default Web Site\simple-rewrite' `<br /> -filter '/system.webserver/rewrite/rules' `<br /> -name "." `<br /> -value @{name=$ruleName; patternSyntax='ECMAScript'; stopProcessing='True'}<br /><br />I've not tested that and you may need to use "$ruleName" instead of $ruleName in the last line. Let me know how you get one.<br /><br />SeanSean Kearonhttps://www.blogger.com/profile/13745810241561834202noreply@blogger.comtag:blogger.com,1999:blog-2285278671879033267.post-51802968998614304082015-01-14T22:25:50.566+00:002015-01-14T22:25:50.566+00:00In this script how to supply the name of the rule ...In this script how to supply the name of the rule through a variableAnonymoushttps://www.blogger.com/profile/02522579788841698529noreply@blogger.com