Kragalon
Kragalon

Reputation: 450

URL Rewrite: PHP variable as directory

Alright, how would I get something like:

domain.com/friends.php?id=Fred

Into something like:

domain.com/Fred/friends.php

Previously, I have used:

RewriteRule ^([A-Za-z0-9]+)$ profile.php?id=$1 [L]

To turn

domain.com/profile.php?id=Fred

Into

domain.com/Fred

I know there is a way to do it, I just don't have the knowledge of the operators that would put that extra 'friends.php' in the RewriteRule. Thanks for the help, if my explanation made sense.

Upvotes: 2

Views: 519

Answers (1)

elixenide
elixenide

Reputation: 44841

You're close:

RewriteRule ^([A-Za-z0-9]+)/friends\.php$ friends.php?id=$1 [L]

Upvotes: 1

Related Questions