Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

IIS Re-Write Rule - Hide Directory (Rule Not Working Correctly)

$
0
0


I have constructed a re-write rule with help from this website.
But I am still having a small problem.

My objective is to remove a certain directory from a URL.

For example:

www.mywebsite.com/uk/editions/

should be re-written to

www.mywebsite.com/editions/

( removing the directory UK )
The above scenario is now working for all URLS, except one.

The UK homepage is physically located here. ( index.html)
www.mywebsite.com/uk/

And the correct re-write rule should display the URL as
www.mywebsite.com

instead it is showing the www root index.html instead of the uk/index.html page.


BUT if I specify the index page within the URL like so
www.mywebsite.com/uk/index.html

it correctly rewrites the URL to
www.mywebsite.com

and shows the UK index page and not the www root index page.

The rule I am using is as follows.

------------------------------------------


I am not sure what I am doing wrong. Here are my rule(s). Thanks

<rule name="Hide UK Directory in URL" enabled="true" stopProcessing="true">
<match url="^uk$|^uk/(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.mywebsite\.com$" />
</conditions>
<action type="Redirect" url="{R:1}" logRewrittenUrl="true" />
</rule>


<rule name="Rewrite the URL after UK is hidden" enabled="true" stopProcessing="true">
<match url="^(?!uk)(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.mywebsite\.com$" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="uk/{R:1}" logRewrittenUrl="true" />
</rule>


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>