getting only part of a url
4 posts
• Page 1 of 1
getting only part of a url
Hello All,
I am slowly getting to grips with this:
say i have the following url:
h t t p : / / domain.com/zone1/zone2/zone3/index.html
or
h t t p : / / domain.com/zone1/zone2/zone3/zone4/index.html
How can I get the last zone before the /index.html, there can be any amount of zones as shown above
Thanks,
Andy
I am slowly getting to grips with this:
say i have the following url:
h t t p : / / domain.com/zone1/zone2/zone3/index.html
or
h t t p : / / domain.com/zone1/zone2/zone3/zone4/index.html
How can I get the last zone before the /index.html, there can be any amount of zones as shown above
Thanks,
Andy
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: getting only part of a url
Hello,
Not sure I understand. What is the initial request and what is the desired result?
Regards
Andrew
Not sure I understand. What is the initial request and what is the desired result?
Regards
Andrew
Re: getting only part of a url
Hello Andrew,
OK I will try an explain it a little better.
Say I have this url
http://domain.com/iMac Parts/iMac_Intel_Parts/iMac_17-inch_Late_2006_CD/products.html
basically I want to be able to use the "iMac_17-inch_Late_2006_CD" from the link to get the id from the database.
but the url could have different depths for example:
http://domain.com/Mac_Mini_Parts/Mac_mi ... ducts.html
Andrew
OK I will try an explain it a little better.
Say I have this url
http://domain.com/iMac Parts/iMac_Intel_Parts/iMac_17-inch_Late_2006_CD/products.html
basically I want to be able to use the "iMac_17-inch_Late_2006_CD" from the link to get the id from the database.
but the url could have different depths for example:
http://domain.com/Mac_Mini_Parts/Mac_mi ... ducts.html
Andrew
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: getting only part of a url
So the regular expression would be:
Regards
Andrew
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP:Host} ^domain\.com$ [NC]
RewriteRule ^.*/([^/]+)/products\.html$ /$1 [NC,L]
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 14 guests