0

I have a problem with my php file. I want to make a site and have the url look like this

domain.com/players/username

i have my folders set up like this: domain.com/players/players.php?username=johndoe

inside the main folder (domain.com/players/index.php) i have a search form that posts to the players.php file so that I want to make it able to search for a player by his username

So -> Remove the /players.php?username=johndoe and change it to /players/johndoe that a user can view their profile at domain.com/players/johndoe

Thank you everyone for the help and sorry if this is a bad question

Ruxie
  • 69
  • 7

1 Answers1

0

Something like this should do the trick,

<IfModule mod_rewrite.c>

# Turn on the engine:
RewriteEngine on

# Set the base to this directory:
RewriteBase /username/

# Redirect certain paths to player.php:
RewriteRule ^(username)/?$ players.php?username=$1

</IfModule>

This is a htaccess file, so you also have to make sure that mod_rewrite is enabled on your server's httpd.conf file.

Hopefully this gets you going in the right direction.