I'm using Tuckey to remove the URL .xhtml extension with the following rules:
<rule>
<from>^/?([a-z-]+)/$</from>
<to>/$1.xhtml</to>
</rule>
<rule>
<from>^/?([a-z-]+)$</from>
<to>/$1.xhtml</to>
</rule>
So /page/ and /page gets mapped to /page.xthml
However, if I have /directory/page/ this doesn't map to /directory/page.xhtml.
<rule>
<from>^/?([a-z-/]+)/$</from>
<to>/$1.xhtml</to>
</rule>
<rule>
<from>^/?([a-z-/]+)$</from>
<to>/$1.xhtml</to>
</rule>
I added the slash into the list of repeatable characters and this worked
use this rule :
<rule>
<from>^/?[a-z-]*?/?([a-z-]+)/$</from>
<to>/$1.xhtml</to>
</rule>
<rule>
<from>^/?[a-z-]*?/?([a-z-]+)$</from>
<to>/$1.xhtml</to>
</rule>
Related
I need to extract all the vanity URLs redirect rules but exclude the redirect rules.
<rule name="welcome2020" stopProcessing="true">
<match url="welcome2020" />
<action type="Redirect" url="https://www.mywebsite.org/Pages/.welcome2020aspx" appendQueryString="false" />
</rule>
<rule name="Page to Page Redirect">
<match url="/Staff/Pages/Ashley.aspx" />
<action type="Rewrite" url="services/Staff/Pages/Ashley.aspx" />
</rule>
i need to match all <match url="whatever" /> types that don't contain .aspx The only thing I have figured out is that I will need a negative lookahead. but not sure how to implement it.
I basically need something like this, but for my redirect rules.
https://www.regextester.com/15
You can just try:
^(?=.*match)(?!.*\.aspx).*
Please see the DEMO :)
I need to check thru URL rewrite if the URL has question mark after 'search-product-list/'. I'm using tuckey. Here's the current rule:
<rule>
<from>^/n/search-product-list/(.*)$</from>
<to last="true" type="permanent-redirect">/ttsvr/search-product-list/$1</to>
</rule>
<rule>
<from>^/search-product-list/(.*)$</from>
<to last="true" type="forward">/n/force-redirect/fitmycar-webdesign-73?query=$1</to>
</rule>
i was able to get the result I expected by doing this:
<rule>
<from>^/search-product-list/(.*)?q(.*)$</from>
<to last="true" type="forward">/n/force-redirect/fitmycar-webdesign-73?query=$1</to>
</rule>
I have the following rule in my webconfig
<rule name="accommidationRewrite2" enabled="true" stopProcessing="true">
<match url="accommodation/(?!results|!property).*?(.*)/" />
<action type="Rewrite" url="/index.cfm/?path=/accommodation/results/params/location/{R:1}/" />
</rule>
I'm trying to get the rule to kick in is the URL is not 'accommodation/results/....' OR 'accommodation/property/.....'
At the moment it only work for the results URL. Can I get it to work for both URL's?
Remove the ! symbol which was present before the property ,
accommodation/(?!results|property).*?(.*)/
I am new to .NET and IIS ans I am trying do a regular expression redirect with this pattern \/([^\/]+)(?=\/[^\/]+\/?$) so my url wil go from mysite.com/en/solutions/exemple to mysite.com/en/exemple but in the redirection IIS put /Service in my URL someone as a idea how to fix this?
here is the rule generated in my web.config by IIS 7
<rewrite>
<rules>
<rule name="redirect salesforce" stopProcessing="true">
<match url="\/([^\/]+)(?=\/[^\/]+\/?$)" />
<action type="Redirect" url="/en/{R:0}/coveo-for-salesforce" appendQueryString="false" />
</rule>
</rules>
</rewrite>
Thanks
UPDATE:I tried
<rewrite>
<rules>
<rule name="remove solutions from url" stopProcessing="true">
<match url="^([^/]+)(/[^/]+)(/.*)" />
<action type="Redirect" url="/{R:0}{R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I get a not not found
Please note that I am working on a Sitecore solution with 2 languages en and fr
If you want to remove the first level folder from the url, e.g.:
/en/solutions/example-page -> /en/example-page
/en/other-folder/another-page -> /en/another-page
/fr/one-more-folder/blah-page -> /fr/blah-page
with the 301 redirect code, use the following rule:
<rewrite>
<rules>
<rule name="remove solutions from url" stopProcessing="true">
<match url="^([^/]+)(/[^/]+)(/.*)" />
<action type="Redirect" url="/{R:1}{R:3}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
If you want to redirect with 301 code from mysite.com/en/solutions/exemple to mysite.com/en/exemple (so in fact remove solutions from all urls (but only if they are directly after language), you can use:
<rewrite>
<rules>
<rule name="remove solutions from url" stopProcessing="true">
<match url="^([^/]+)/solutions(/.*)" />
<action type="Redirect" url="/{R:1}{R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
I've tested the solution on Sitecore application and it definitely works.
I am trying to match all urls in web.config that don't contain the string "scadmin1" but do contain "/admin".
According to RegexPal (a website), the following Regex should work:
^(?:(?!\.scadmin1).)*/admin$?
It isn't working in the web.config file however. Here's my complete rewrite rule:
<rule name="RedirectAllAdminRequestsToAdminArea">
<match url="^(?:(?!\.scadmin1).)*/admin$" />
<action type="Redirect" url="http://scadmin1.myurl.com/admin"
appendQueryString="False" redirectType="Permanent" />
</rule>
Thanks for the help.