Quantcast
Channel: Configuration & Scripting
Viewing all articles
Browse latest Browse all 780

My Goal to Redirect Some URLs

$
0
0

Recently I've upgraded some components of my CMS and now I need to create some IIS 8.5 redirect rules.

I've urls with depth levels. For instance

http://www.example.com/dogu-anadolu

and

http://www.example.com/ege

 for first level pages.

I want to redirect these to new urls (the pages exists) like

http://www.example.com/pansiyonlar/dogu-anadolu
http://www.example.com/pansiyonlar/ege

 etc.

For second level:

http://www.example.com/karadeniz/samsun-pansiyonlari

should be redirected to 

http://www.example.com/pansiyonlar/karadeniz/samsun

My goal is to remove pansiyonlari from end and place words karadeniz and samsun after /pansiyonlar

karadeniz is a region and samsun is a city under karadeniz. My goal is to match both words at this part using Regex. For example another example would be ic-anadolu as region name and city as Ankara. In this case:

http://www.example.com/ic-anadolu/ankara-pansiyonlari

must be redirected to

http://www.example.com/pansiyonlar/ic-anadolu/ankara

I've to repeat this process for third level, forth level and maybe fifth level if it is necessary in the feature. Starting with second level the wordpansiyonlari is specified at every new level:

http://example.com/akdeniz/burdur-pansiyonlari/altinyayla-pansiyonlari

Urls like above should go to:

http://example.com/pansiyonlar/akdeniz/burdur/altinyayla

I have started with following rule as an experiment.

<rule name="RedirectUserFriendlyURL1" stopProcessing="true"><match url="^([^/]+)/([^/]+)-pansiyonlari" /><conditions><add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /></conditions><action type="Redirect" url="pansiyonlar/{R:1}/{R:2}/" appendQueryString="false" /></rule>

It works for second level pages, but redirects third level and forth level pages to new urls for second level. Can I simplify this process into a few working rules?

Any ideas?


Viewing all articles
Browse latest Browse all 780

Trending Articles



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