View Full Version : Mod Rewrite Help


chachi
11-03-2004, 11:59 AM
I posted this over at Morgan's Mod Rewrite Forum (http://www.mod-rewrite.com/forum/thread94.html), but since I am not sure anyone goes there anymore I figured I would ask here as well.

I am trying to figure out how to use Mod Rewrite to allow the use of page names like:

www. domain.com/products/one-two.html

when the actual URL is:

www. domain.com/products/?search=one+two

I lose it when I try and use more than one word as the search string. I would like to use one word, two word, and more than two word seach strings and have the page name be the search terms separated with hyphens and end with .html.

If anyone can show me how to do this, I would be most grateful.

UnXpected
11-03-2004, 12:23 PM
www. domain.com/products/one-two.html

i am not sure whether can it become -

but www. domain.com/products/one+two.html you can 8-|


Look at this site: http://www.mtgcardplace.com


all url = www. domain.com/products/one+two/

UnXpected
11-03-2004, 12:30 PM
maybe you can try this

RewriteRule ^products/[a-zA-Z]*)-[a-zA-Z]*).html ?search=$1+$2 [L,NC]


Not sure it work.

chachi
11-03-2004, 01:00 PM
thanks, I know it can be done better than that though. Here is what I have now:

RewriteRule ^/(.*)$ /products/?search=$1 [passthrough,type=application/x-httpd-php]
RewriteRule ^products/([A-Za-z]*)-([A-Za-z]*) /products/?search=$1+$2

That will work for 2 word search strings, but I would like to be able to do it with one word or five. Anyone know if this is possible or how to do it?

UnXpected
11-03-2004, 08:17 PM
Try to repeat it

RewriteRule ^products/([A-Za-z]*)-([A-Za-z]*) /products/?search=$1+$2
RewriteRule ^products/([A-Za-z]*)-([A-Za-z]*)-([A-Za-z]*) /products/?search=$1+$2+$3
RewriteRule ^products/([A-Za-z]*)-([A-Za-z]*)-([A-Za-z]-([A-Za-z]*)*) /products/?search=$1+$2+$3+$4
RewriteRule ^products/([A-Za-z]*)-([A-Za-z]*)-([A-Za-z]*)-([A-Za-z]*) -([A-Za-z]*)/products/?search=$1+$2+$3+$4+$5

PuReWebDev
11-26-2004, 08:15 AM
Try this, I think it might be what you are trying to do, I didn't test it, so sorry if it doesn't come out the way you want.

RewriteRule ^products/one-two.html products/?search=one+two

or

RewriteRule ^/one-two.html /?search=one+two


Hope this post helped.


Thanks,
--PuRe