Baldy
Baldy

Reputation: 3669

IIS URL Rewrite pattern from subdirectory to subdomain with custom path extraction

Previously there was this...

http://www.website.com/blog/post/2013/04/16/Animal-Kingdom's-Wild-Africa-Trek.aspx

(notice the apostrophe in 'Kingdom's')

and its now located at:

http://blog.website.com/post/Animal-Kingdoms-Wild-Africa-Trek

so, breaking it down the parts are...

remove .aspx from the end of the URL map the call from www. to blog. and remove the blog part of the path remove the date from the URL remove the apostrophe

I understand how to redirect the subdirectory to a subdomain, but im stuck extracting the other parts of the path correctly, and cleaning out the apostrophe too.

A complete solution would be a great help, thanks in advance.

Upvotes: 0

Views: 489

Answers (1)

Piotr Stapp
Piotr Stapp

Reputation: 19820

There is no way to remove all ', because it can be more than one. You could try following regexp (it allows up to 4 apostrophes), but it is quite "danger":

/blog/post/\d+/\d+/\d+/(([^']*)'*([^']*)'*([^']*)'*([^']*)'*).aspx

And redirect URL will be:

http://blog.website.com/post/{R:2}{R:3}{R:4}{R:5}

Bellow screenshot of my IIS Rule: enter image description here

Upvotes: 1

Related Questions