neojakey
neojakey

Reputation: 1663

URL Rewrite Regular Expressions

Morning All,

I have classified ads with various categories and sub categories and I want to do a url rewrite using IIS7. I need to make up a regular expression that could possibly have up to 5 categories and sub categories for example:

http://westpalmbeach.storeboard.com/classifieds/for-sale/electronics/looking-for-a-cheap-touchscreen-laptop/390

or

http://tampa.storeboard.com/classifieds/jobs/work-from-home/social-media-networker/380

notice the numerical value at the end of each url, this is the part I am interested in retrieving as it is the ID for the eventual URL which would be:

http://tampa.storeboard.com/classifieds/viewad.asp?RegionID=23&ClassAdID=390

How can I create a regular expression that can hunt out the integer on the end and also extract the domain name e.g. tampa.storeboard.com

Many thanks for your help.

Best Regards, Paul

Upvotes: 0

Views: 894

Answers (2)

τεκ
τεκ

Reputation: 3114

RewriteCond REQUEST_URI !/classifieds/viewad.asp
RewriteRule /classifieds/.*/(\d*)$ /classifieds/viewad.asp?Region=%{HTTP_HOST}&ClassAdID=$1

Upvotes: 0

Gursel Koca
Gursel Koca

Reputation: 21300

^http://([^/]+).*?(\d+)$

group 1 for domain name , and group 2 is for ID. It has been tested with RAD regular expression designer.

Upvotes: 2

Related Questions