Page 1 of 1

mind boggling mod_rewrite issue

Posted: Mon Feb 06, 2006 6:15 pm
by bg
I'm having a helluva time figuring out how to get mod_rewrite to do what I want. Basically, My web app runs completely off of the index.php in the root dir, and acts depending on the string passed to it, for example www.website.com/index.php?m=user&f=view_profile where m is the current module being accessed and f is the current function within that module which is being run. I want mod_rewrite to take that url and format it to www.website.com/module_name/function_name.html. While this isn't too hard, here is the catch. Each module has a default function, so if no function, f, is specified, then the web app automatically loads the default function for that particular module. In this case, the query string would only specify the module, m. If this happens to be the case, I would like it to display the url as such www.website.com/module/. It seems to me, this would require some sort of conditional statement within the .htaccess file.

This is all I have so far, which only works if just the module is specified.

Code: Select all

RewriteEngine on
RewriteRule ^([^/]+)/$	index.php?m=$1 [L]
Any help would be greatly appreciated!

Posted: Thu Feb 09, 2006 7:29 pm
by josh

Code: Select all

RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)\.html$   index.php?m=$1&f=$2
RewriteRule ^([^/]+)/$   index.php?m=$1
If /module/ is accessed then $_GET['f'] will not be set