Need help with RewriteRule

Topics: User Forum
Mar 18, 2010 at 8:08 PM
Edited Mar 18, 2010 at 8:18 PM

I need to be able to take a URL like http://www.server.com/cooking/eggs/ and get to http://www.server.com/?type=cooking&what=eggs

I know I don't want to redirect since this will be for SEO purposes.  What I have so far is: RewriteRule (https?)://([^/]+)/([^/]+)(/([^\?]+(\?(.*))?)?)? $1://$2/?type=$3&what=$5

I got the regular expression from the documentation.  It worked better than what I had.  I seem to be having problems converting the folder names to parameters.  It was creating: http://www.server.com/cooking/eggs/?type=cooking&what=eggs which is why I added the scheme and server to the regular expression.  The documentation has led me to believe I should use RewiteCond for that part.  I couldn't figure that out though.  So, do I need both RewriteCond and RewriteRule or can this be done just using RewriteRule?  My final result now is: REWRITE 'http://www.server.com/cooking/eggs/' ==> 'http://www.server.com/?type=?
type=?type=?type=?type=?type=?type=?type=?type=cooking&what=eggs&what=&what=&wha
t=&what=&what=&what=&what=&what=' using TestDriver

The depth seems to be going past 8 so I'm missing the final what= not to mention the repeating.  Even when I altered the IterationLimit above 8 it didn't help.

Mar 19, 2010 at 1:44 PM

OK, I think I'm good now.  I found the example I needed in the SearchEngineFriendly folder under tests.

Coordinator
Mar 19, 2010 at 7:25 PM

ah, great, glad you found it.