Page 1 of 1

mod_rewrite help needed badly. [SOLVED]

Posted: Wed Jan 12, 2011 8:37 pm
by spedula
:offtopic:
I wasn't able to find a section on this forum for .htaccess questions and the only .htaccess forum I could find online wasn't active at all. So sorry for posting in the wrong section but I need help badly. If I missed the section for this topic, please move it to the right board, thanks.

I'm trying to create pretty URL's for my web app. I have that part working correctly, so going to domain.com/bar/ will really be domain.com/index.php?foo=bar

I need to know if it's possible to still use key=values in the pretty URL and how to do it properly.

I want the URL to look like this domain.com/bar?category=1&product=1&etc=etc...

But for the behind the scenes will be this domain.com/index.php?foo=bar&category=1&product=1&etc=etc...

I've gotten so far as to even realize RewriteCond %{QUERY_STRING} has something to do with it, but I'm completely lost after that. About 7 hours of trial and error later I'm still only get errors :banghead:

Thanks for any help in advance.

Re: mod_rewrite help needed badly.

Posted: Wed Jan 12, 2011 11:02 pm
by spedula
I figured it out. In case anyone need to know. Here's how it's done.

Code: Select all

Options +FollowSymlinks
RewriteEngine On 

RewriteCond %{QUERY_STRING} cat=(.*)
RewriteRule ^search\.php$ index\.php?page=search&cat=%1 [L]

RewriteRule ^([^/]*)/$ index\.php?page=$1
PM me if you need an explanation.