Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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]

Try this

RewriteRule ^Minecraft-User-Info/player/([a-zA-Z0-9_-]+)\$ index.php?playerId=$1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top