.htaccess help

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

.htaccess help

Post by Live24x7 »

Hello

I need to replace this exact url string :

/usr/userinfo.php?user=foo

by

/foo

I understand i need to do this with .htacess. But I have not been able to do that with google ssearches on the topic.

Any help would be greatly appreciated.

Thanks a lot
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: .htaccess help

Post by pickle »

You want to use mod_rewrite.

Just off the top of my head, it'll be something like this:

[syntax]RewriteEngine On
RewriteBase /
RewriteRule ^foo$ usr/userinfo.php?user=foo[/syntax]

Now that you know, you should be able to Google for the right stuff - you are far from the first person to have questions about mod_rewrite, so there is tons of info out there.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: .htaccess help

Post by Live24x7 »

thanks for answering.

There are plenty of answers available in google search. The issue is the term foo is to be replaced by a regex and none of the regex stuff seems to be working on my localhost

thanks anyways
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: .htaccess help

Post by pickle »

Check that you actually have mod_rewrite installed.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: .htaccess help

Post by Live24x7 »

thanks i guess that was the problem :) it works now
Post Reply