Need some basic mod_rewrite help

Hello,

So I am trying to use mod_rewrite to run some dynamic php. I would like to be able to go to mysite.com/articles.php?uid=something and have it substitute the uid value into this:

[php]<?php echo $apicms->content(uid)->getHtml(); ?>[/php]

And then spit back a url in the url bar that looks like this: mysite.com/articles/uid

And if it is at all possible make it so that if I go to mysite.com/articles/uid it would be able to re-run the dynamic php

hi,

Try this.
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

But then how do I setup the code so that it reads the “?uid=something” part of the url and inserts the uid variable here?

[php]<?php echo $apicms->content(uid)->getHtml(); ?>[/php]

If the url is: [tt]mysite.com/articles.php?uid=something[/tt]

then, in [tt]articles.php[/tt] you access the uid value using $_GET:

[php]echo $_GET[‘uid’];
// OR
$uid = $_GET[‘uid’];
print($uid);[/php]

The code works David. Many thanks! My last problem is just that I have very little knowledge of mod_rewrite. All I know is that it involves a .htaccess file, but I am utterly confused by the online tutorials I have found. I just need the url to go from mysite.com/articles.php?uid=something to mysite.com/articles/uid and be reverse compatible if possible. Any help is greatly appreciated, as I have close to no idea what I am doing.

Thanks!!!

Sponsor our Newsletter | Privacy Policy | Terms of Service