0

I got a webpage that has the following URL:

localhost/Minecraft-User-Info/player/?user=matthijs110

Now I want it to localhost/Minecraft-User-Info/player/matthijs110

So without ?user=matthijs110

I tried different ways, but it doesn't seem to work. Mod_Rewrite is enabled.

What can I do to get this to work?

Howli
  • 11,925
  • 19
  • 46
  • 70
Matt
  • 59
  • 7

3 Answers3

1

Give this a try.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Minecraft-User-Info/player/(.+)$ /Minecraft-User-Info/player/?user=$1 [L]

Edit: Use this since it's in a sub directory.

RewriteEngine On
RewriteBase /Minecraft-User-Info/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^player/(.+)$ player/?user=$1 [L]

Updated to show my original answer and included the edit per users comment about where htaccess is located.

Panama Jack
  • 23,667
  • 10
  • 61
  • 93
  • Ok then try adding the RewriteBase since your htaccess file is in the `Minecraft-User-Info` directory. And try it this way. – Panama Jack May 11 '14 at 15:31
1

Try this instead. Minecraft-User-Info/player/username Redirects to Minecraft-User-Info/player/index.php?user=username
Tested on http://htaccess.madewithlove.be/ instead of setting up my own server for it.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Minecraft-User-Info/player/(.+)$ /Minecraft-User-Info/player/index.php?user=$1 [L]
Frederik Spang
  • 3,070
  • 26
  • 42
0

Try this

RewriteRule ^Minecraft-User-Info/player/([a-zA-Z0-9_-]+)\$ index.php?playerId=$1
TED
  • 1,761
  • 4
  • 17
  • 36
  • well so in the index.php you have to define the template for the particular playerId you are parsing do you? – TED May 11 '14 at 14:28
  • did you check you are getting the player id index.php? bcz this way we are getting request through index – TED May 11 '14 at 14:33
  • @GayanChathuranga that's not what he asked for. He's not using a friendly link that ends in html. This is will not work for what he's asking for. – Panama Jack May 11 '14 at 14:39