I am working on a CMS that involves custom user pages. I have a hierarchy with three levels set up, and it works pretty well. It's got a .htaccess that makes the URLs friendlier, too:
RewriteRule ^([A-Za-z0-9]+).html /content.php?page=$1 [L]
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+).html /content.php?page=$2 [L]
RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/([A-Za-z0-9]+).html /content.php?page=$3 [L]
That code works just fine.
Another feature that I have is adding custom php page, in case I need to add something more powerful (like make a contact form that gets email addresses from a database).
So my question is how could I modify (or add to) the .htaccess to make all of the GET parameters passed to the PHP page. For example, to use the contact page example, if the user goes to http://www.mysite.com/contact.html?name=someuser, I want the .htaccess to rewrite it as content.php?page=contact&name=someuser, but without specifically telling it to look for 'name' as the parameter name. I would also like it to work with as many parameters as possible.
I know this is a big (and hopefully not confusing) request, but is it possible? Or at least parts of it? Thanks!
add QSA to your parameters. so for your first rule it would become
RewriteRule ^([A-Za-z0-9]+).html /content.php?page=$1 [L, QSA]
You'll need to use the QSA (query string append) flag. The mod_rewrite documentation has more detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With