• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

mod_rewrite

Modeps

Lifer
I presume that I need to use Mod_rewritemod_rewrite to accomplish this, and if not, maybe someone can point me in the right direction.

I've got a PHP/MySQL website. Almost all of the content is served off of url variables like id=1

What I'd like to do is instead of having something like:

http://foo.com/user.php?id=1

is to allow for:

http://foo.com/user/modeps

Is there a quick solution? I could use a hand, as I've never done anyting with mod_rewrite before.
 
in your .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} ^foo\.com
RewriteRule ^user/(.*)?$ user.php?userName=$1 [L]




then in your user.php, change the query to use $_GET['userName'] instead of the userId.
you should also validate it before querying for it, url decode, addslashes, whatever floats your boat 🙂
 
i think the 2nd line is unnecessary, but it was in my htaccess, so i pasted it here too 🙂

if you get a server error, you'll need to enable mod_rewrite in httpd.conf
(just find the #LoadModule rewrite_module modules/mod_rewrite.so and remove the #)
 
Awesome, it worked wonderfully... thank you for your help 🙂
Much easier than I thought it would be too. 😀
 
no prob
if you need more than one variable, you can just do


RewriteRule ^fakepath/(.*)/(.*)?$ realpath/realscript.php?var1=$1&var2=$2
 
Back
Top