You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by klute <so...@yahoo.com> on 2005/08/05 15:17:01 UTC

[users@httpd] mod_cond/mod_rewrite help needed

Hello all,

I am having a hard time writing the following
cond/rule:

Part 1 (easy)
If user requests
/search/<keywords>/<category>/<sortby>/<sorttype>
where keywords is an actual string, the following
should be invoked:
/search.php?keyword=<keywords>&category=<category>&sortby=<sortby>&sorttype=<sorttype>


Part 2 (not-so-easy)
If user requests
/search/<keywords>/<category>/<sortby>/<sorttype>
where "|" is listed as any of the params (meaning no
filtering for that param is needed), do not use that
param in the search filter. It would be nice to be
able to exclude such params from the query string
(i.e. /search.php?keyword=seo&category=webmaster when
the original search contained
/search/seo/webmaster/|/| -- only <keywords> and
<category> are supplied )


I believe it is a combination of RewriteCond and
RewriteRule that needs to be applied but have no
experience of dealing with the former.

Any help will be greatly appreciated!
James

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteCond help needed

Posted by klute <so...@yahoo.com>.
Joshua,

Thanks a lot. Actually .php was given as an example,
the search will most likely be directed to a java
servlet.

Can you point me to any examples of how to set a bunch
of ENV variables based on URL. Hopefully, it won't be
that ugly (the complex part I don't mind)

Thanks a lot,
James

--- Joshua Slive <js...@gmail.com> wrote:

> On 8/5/05, klute <so...@yahoo.com> wrote:
> > Part 2 (not-so-easy)
> > If user requests
> > /search/<keywords>/<category>/<sortby>/<sorttype>
> > where "|" is listed as any of the params (meaning
> no
> > filtering for that param is needed), do not use
> that
> > param in the search filter. It would be nice to be
> > able to exclude such params from the query string
> > (i.e. /search.php?keyword=seo&category=webmaster
> when
> > the original search contained
> > /search/seo/webmaster/|/| -- only <keywords> and
> > <category> are supplied )
> > 
> > 
> > I believe it is a combination of RewriteCond and
> > RewriteRule that needs to be applied but have no
> > experience of dealing with the former.
> 
> This could be done using mod_rewrite by setting a
> bunch of env
> variables based on the URL, but it would be complex
> and ugly. 
> Considering you are already using php, why don't you
> just have a php
> script grab those URLs, parse the PATH_INFO and call
> your search page?
> 
> Joshua.
> 
>
---------------------------------------------------------------------
> The official User-To-User support forum of the
> Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for
> more info.
> To unsubscribe, e-mail:
> users-unsubscribe@httpd.apache.org
>    "   from the digest:
> users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail:
> users-help@httpd.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_cond/mod_rewrite help needed

Posted by Joshua Slive <js...@gmail.com>.
On 8/5/05, klute <so...@yahoo.com> wrote:
> Part 2 (not-so-easy)
> If user requests
> /search/<keywords>/<category>/<sortby>/<sorttype>
> where "|" is listed as any of the params (meaning no
> filtering for that param is needed), do not use that
> param in the search filter. It would be nice to be
> able to exclude such params from the query string
> (i.e. /search.php?keyword=seo&category=webmaster when
> the original search contained
> /search/seo/webmaster/|/| -- only <keywords> and
> <category> are supplied )
> 
> 
> I believe it is a combination of RewriteCond and
> RewriteRule that needs to be applied but have no
> experience of dealing with the former.

This could be done using mod_rewrite by setting a bunch of env
variables based on the URL, but it would be complex and ugly. 
Considering you are already using php, why don't you just have a php
script grab those URLs, parse the PATH_INFO and call your search page?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org