Click to See Complete Forum and Search --> : One rule, many cases


punctweb
10-07-2008, 10:38 AM
Hello all,

Here is my problem:

i have RewriteRule that looks like this

RewriteRule find\.html/(.*)/([0-9]+) search.php?q=$1&page=$2
RewriteRule find\.html/(.*) search.php?q=$1
RewriteRule find\.html$ search.php

The url would be

http://www.somesite.com/find.html
http://www.somesite.com/find.html/somecriteria/
http://www.somesite.com/find.html/somecriteria/2

The above works fine.

But, sometimes, the url changes in

http://www.somesite.com/fr/find.html
http://www.somesite.com/fr/find.html/somecriteria/
http://www.somesite.com/fr/find.html/somecriteria/2

The fr/ part apears when multiple languages are in effect...

The url can be also

http://www.somesite.com/en/find.html or http://www.somesite.com/jp/find.html etc

I tried


RewriteRule ^(.*)/?find\.html/(.*)/([0-9]+) search.php?q=$1&page=$2
RewriteRule ^(.*)/?find\.html/(.*) search.php?q=$1
RewriteRule ^(.*)/?find\.html$ search.php

but the GET parameters do not mach in both cases, with or without the language set...

How should i write the rewrite rule in order to comply in both cases: with or without language set ?

I hope i was clear in my explication...

Thank you in advance.

Shorts
10-07-2008, 01:49 PM
makes the search.php?q=$2&page=$3 and search.php?q=$2 respectively. the ^(.*) is $1

punctweb
10-08-2008, 03:46 AM
yes, i know that... the problem is exactly that first element... it is optional... i need the same rule to work the same with or without it...

Thank you

chazzy
10-09-2008, 06:31 AM
maybe I'm missing something, but what exactly doesn't work? it looks like, based on your rules, that no matter what entered, the search.php is in the same place (which is relative to something else?)

punctweb
10-09-2008, 06:52 AM
In a real world example, i have an website in three languages: english, japanese and french

The default URL of the website is (with the english language as default)
http://www.somesite.com/
When i whant to see the website in japanese or french, the url becomes
http://www.somesite.com/jp/
or
http://www.somesite.com/fr/

The fr/ and jp/ are not real directories on server

Now, if i access (there is only one file that serve the content and that is search.php)

http://www.somesite.com/find.html it works ok
http://www.somesite.com/fr/find.html it works ok
http://www.somesite.com/jp/find.html it works ok

But if i add more parameters in that URL, like

http://www.somesite.com/find.html/some+criteria/2
http://www.somesite.com/fr/find.html/some+criteria/2
http://www.somesite.com/jp/find.html/some+criteria/2

for the two cases in which the language is set, the "2" parameter (the page number) is not set anymore in a GET variable

Anyway, the problem was solved in the meantime with these rules

RewriteRule ^(?:(.+){2}/)?find/(.*)/([0-9]+) search.php?q=$2&page=$3 [L]
RewriteRule ^(?:(.+){2}/)?find/(.*)/ search.php?q=$2 [L]
RewriteRule ^(?:(.+){2}/)?find/ search.php?q=$2

Thank you