-1

I coded an online statistics page for my (minecraft) server, but I am having problems while trying to rewrite the url's to make it easier

I want to rewrite:

domain.com/players/player.php?p=QUERY

to:

domain.com/player/QUERY

I searched many pages, but many things didn't work. Right now I am stuck with this:

<IfModule mod_rewrite.c>  
    RewriteEngine on
    RewriteRule ^player/(.*)$ players/player.php?p=$1 [NC]
</IfModule>

If you could help me, that would be extremely great and very kind.

PS: the QUERY will be a String with the max length of 16 and containing numbers, letters and minusses, if that matters.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183

1 Answers1

1
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /players/(player)\.php\?p=([a-z0-9-]{1,16}) [NC]
RewriteRule ^ /%1/%2? [R=301,L]

RewriteRule ^player/([a-z0-9-]{1,16})$ /players/player.php?p=$1 [NC,L]
hjpotter92
  • 78,589
  • 36
  • 144
  • 183