PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Aug 15, 2020 2:54 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: .htaccess help
PostPosted: Fri May 25, 2012 7:52 am 
Offline
Forum Contributor

Joined: Sat Nov 19, 2011 10:32 am
Posts: 194
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


Top
 Profile  
 
 Post subject: Re: .htaccess help
PostPosted: Fri May 25, 2012 5:36 pm 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6446
Location: 53.01N x 112.48W
You want to use mod_rewrite.

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

Syntax: [ Download ] [ Hide ]
  1. RewriteEngine On 
  2. RewriteBase / 
  3. RewriteRule ^foo$ usr/userinfo.php?user=foo 


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.


Top
 Profile  
 
 Post subject: Re: .htaccess help
PostPosted: Fri May 25, 2012 9:42 pm 
Offline
Forum Contributor

Joined: Sat Nov 19, 2011 10:32 am
Posts: 194
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


Top
 Profile  
 
 Post subject: Re: .htaccess help
PostPosted: Mon May 28, 2012 9:44 am 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6446
Location: 53.01N x 112.48W
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.


Top
 Profile  
 
 Post subject: Re: .htaccess help
PostPosted: Mon May 28, 2012 1:41 pm 
Offline
Forum Contributor

Joined: Sat Nov 19, 2011 10:32 am
Posts: 194
thanks i guess that was the problem :) it works now


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group