Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Rewrite Rule and GeoPath Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 12 March 2010 at 9:16am | IP Logged Quote durabo

Hi (sorry for my english),

i have a problem with my rewrite rule.

This URLs:
www.mydomain.com/area/state/region/city/month
www.mydomain.com/area/state/region/month
www.mydomain.com/area/state/region/type/month
www.mydomain.com/area/state/region/city/type/month

the problem is in the middle because it is variable in
length but separator must always be "/"... the result is:

www.mydomain.com/area/default.asp?
Geo=<geo>&month=<month>&type=<type>

i use: ([^/]+)/([^/]+), but obviously not working

any suggestion?

thanks in advance,
pierpaolo
Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 12 March 2010 at 9:46am | IP Logged Quote Anton

So, you want all of the above to be assigned to correct query string variables, right?
So www.mydomain.com/area/state/region/city/month gets www.mydomain.com/area/default.asp?state=<state>®ion=<region>&city=<city>&month=<month>
and
www.mydomain.com/area/state/region/month gets www.mydomain.com/area/default.asp?state=<state>®ion=<region>&month=<month>

Right?

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 12 March 2010 at 9:56am | IP Logged Quote durabo

No... a geo path is unique:

example:
www.mydomain.com/area/state/region/month
call
default.asp?Geo=state/region&month=<month>&type=

or
www.mydomain.com/area/state/region/city/type/month
call
default.asp?
Geo=state/region/city&month=<month>&type=<type>

many thanks,
pierpaolo
Back to Top View durabo's Profile Search for other posts by durabo
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 12 March 2010 at 12:02pm | IP Logged Quote durabo

Dear Anton,

I could adapt my work to your proposal. Can you help me to
build the pattern?

Thanks in advance,
Pierpaolo
Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 15 March 2010 at 2:58am | IP Logged Quote Anton

Ok. I guess I see what you want. And that's gonna be really difficult to accomplish...
How about adding some identifiers to the URL structure to make it easier to detect Geo part and the others?
"but separator must always be "/"" - no way to change this?
It would be great to have it like this: www.mydomain.com/area/state-region/month, www.mydomain.com/area/state-region-city/type/month.
If we don't invent something, we'll have to deal with 4-5 mapfiles and numerous conditions...

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 15 March 2010 at 3:54am | IP Logged Quote durabo

Ok Anton,

try with your suggestion. Let's see if the customer likes it or not.
Already have an example of a pattern?

Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 15 March 2010 at 4:37am | IP Logged Quote Anton

You mean the rules? Yes, sure:

RewriteBase /
RewriteRule ^area/([^/]+)(?:/([^/]+))?/([^/]+)$ default.asp?Geo=$1&month=$3(?2&type=$2) [NC,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 15 March 2010 at 6:09am | IP Logged Quote durabo

Good Anton and my thanks.

Can you explain to me?

(?2&type=$2) is similar to an if?

If add "/pag/2" e "pag/3" ... at the end of URL for paging functionality don't work.

sorry and many many thanks

Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 15 March 2010 at 6:41am | IP Logged Quote Anton

"(?2&type=$2) is similar to an if?" - yes, exactly.

"If add "/pag/2" e "pag/3" ... at the end of URL for paging functionality don't work." - I haven't accounted for such case. Is it also
optional?

Please try to have the following:

RewriteBase /
RewriteRule ^area/([^/]+)(?:/([^/]+))?/([^/]+)(?:/pag/(\d+))?$ default.asp?Geo=$1&month=$3(?2&type=$2)(?4&pag=$4) [NC,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 15 March 2010 at 8:38am | IP Logged Quote durabo

many many thanks Anton,

can you explain "in words" this:
(?:/([^/]+))

and this:
?/([^/]+)

regards,
pierpaolo

Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 15 March 2010 at 8:52am | IP Logged Quote Anton

Well, the construction is like this

(?:/([^/]+))?

"?:" tells that this shouldn't be matched (and back reference won't be assigned)
"?" means that /([^/]+) may exist or not
"([^/]+)" this is what gets matched and referenced as $2

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 15 March 2010 at 1:29pm | IP Logged Quote durabo

well... and the last:

"$" at the end?

This url it's ok:
/area/geo/month
/area/geo/month/pag/3

this url not work:
/area/geo/month/
/area/geo/month/pag/3/
/area/geo

rgds,
pier



Edited by durabo - 15 March 2010 at 6:41pm
Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 16 March 2010 at 6:14am | IP Logged Quote Anton

"$" at the end means the end of the string.

"this url not work:
/area/geo/month/
/area/geo/month/pag/3/
/area/geo" - you ask more and more each time :)

Please fix your config like this:

RewriteBase /
RewriteRule ^area/([^/]+)(?:/([^/]+))?(?:/([^/]+))?(?:/pag/(\d+))?/?$ default.asp?Geo=$1(?3&month=$3)(?2&type=$2)(?4&pag=$4) [NC,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 16 March 2010 at 12:04pm | IP Logged Quote durabo

thanks anton. you were really valuable and friendly
Back to Top View durabo's Profile Search for other posts by durabo
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 07 April 2010 at 12:39pm | IP Logged Quote durabo

Hi Anton,

sorry to disturb you, but I have a problem from which it can not get out.

I have two type of URL:

www.domain.com/it/events/month/state/region/city/type/

www.domain.com/it/events/state/region/city/type/

I apply this pattern:

RewriteRule ^it/eventi/(\w+)/(.*)/(.*)/(.*)$ /it/events/events.asp?month=$1&geo=$2&type=$3&pg=1

the problem is that pattern work good with url www.domain.com/it/events/month/state/region/city/type/ but not with second example.

can i create conditional pattern for the "month" area?

 

many many thanks for your help.

Best regards,

pierpaolo


Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 08 April 2010 at 5:11am | IP Logged Quote Anton

"I apply this pattern:

RewriteRule ^it/eventi/(\w+)/(.*)/(.*)/(.*)$ /it/events/events.asp?month=$1&geo=$2&type=$3&pg=1

the problem is that pattern work good with url www.domain.com/it/events/month/state/region/city/type/ but not with second example."

It looks that you've made some misprint as your pattern has 4 submatches (parentheses) and you address only 3 of them in the right part of the rule ($1..$3).
Moreover, if (\w+) matches 'month', then you have 3 (.*) left for 4 parameters: /state/region/city/type/, is that correct?
Please clarify.

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 08 April 2010 at 5:49am | IP Logged Quote durabo

Thanks Anton,

3 parameter at all

second parameter: "state/region/city" is second parameter
first parameter is "month" but is optional
third parameter is "type" but is optional

second parameter keep this value:
"state/region/city" or "state/region" or "state"

the problem is first and third optional parameter

many thanks for all,
Pierpaolo
Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 08 April 2010 at 6:36am | IP Logged Quote Anton

Ok, I see now.
Then lets try the following rule:

RewriteRule ^it/events(?:/(\w+))?/(.+?)(?:/([^/]+))?$ /it/events/events.asp?(?1month=$1&)geo=$2(?3&type=$3)&pg=1

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
durabo
Newbie
Newbie


Joined: 25 February 2010
Online Status: Offline
Posts: 19
Posted: 08 April 2010 at 12:42pm | IP Logged Quote durabo

thanks Anton,

but work with:
it/events/may/italy/lazio/rome/type

and not work with:
it/events/italy/lazio/rome/type

this response value:
$0:     it/events/italy/lazio/rome/type
$1:     italy
$2:     lazio/rome
$3:     type

correct version is:
$0:     it/events/italy/lazio/rome/type
$1:     
$2:     italy/lazio/rome
$3:     type

when $1 is optional month... :-(

rgds,
pierpaolo


Edited by durabo - 08 April 2010 at 12:43pm
Back to Top View durabo's Profile Search for other posts by durabo
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 09 April 2010 at 1:31am | IP Logged Quote Anton

I see... Let's try it the following way - as the months number is limited, we may just list them all:

RewriteRule ^it/events(?:/(january|february|march|april|may|june|july|august|september|october|november|december))?/(.+?)(?:/([^/]+))?$
/it/events/events.asp?(?1month=$1&)geo=$2(?3&type=$3)&pg=1 [NC,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

Page of 2 Next >>
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum