Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help with mod_rewrite 1

Status
Not open for further replies.

gmail2

Programmer
Jun 15, 2005
987
IE
I've got a php file called author.php which will pull a record from a db dependent on a given id in the URL. HOwever, I want to be able to access them like this instead:
/authors/1

Here's what I've got in my .htaccess:
Code:
RewriteEngine on
RewriteBase /beta
RewriteRule ^authors/*$ author.php?$1 [T=application/x-httpd-php]

I'm not very well up on regex so I'm not too sure what I'm doing wrong. What I thought I was saying was that anything that had a url authors/idhere would be passed as author.php?iidhere but it doesn't seem to work. Can somebody help me oout a bit?
 
Hi

The asterisk ( * ) character is a multiplier of the previous character. So your expression will match a string which starts with the characters "authors" and ends with zero or more "/" characters. Probably you want to match any count of any characters, which is written as [tt].*[/tt] .

Beside this, if you want to reinsert a character group, as [tt]$1[/tt], you must capture them first with parenthesis ( ( ) ), like this : [tt](.*)[/tt] .

Theoretically ( not tried, could be other errors ) :
Code:
RewriteRule ^authors/[red](.[/red]*[red])[/red]$ author.php?$1 [T=application/x-httpd-php]

Feherke.
 
feherke - thanks so much, I was reading up on reg ex but like I said, I know very little about it. Thanks for explaining it so well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top