0

By using .htaccess I have been able to turn the URL:
http://www.websitename.co.uk/directory/users.php?id=idValue&data2=data2Value
Into
http://www.websitename.co.uk/directory/users?id=idValue&data2=data2Value

HTAccess:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

However, I would much rather like to see it turned into this:
http://www.websitename.co.uk/directory/users/idValue?data2=data2Value

I hope that makes sense, for now just echoing the idValue is all I would need help with on the PHP side as I am unsure how?

lmpclk
  • 75
  • 1
  • 9
  • Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Masivuye Cokile Feb 06 '18 at 12:12

1 Answers1

0
RewriteRule ^directory/users/([0-9_]+)/([A-Za-z0-9_]+)$ directory/users.php?id=$1&data2=$2 [L,QSA]

duplicate

Nikita
  • 408
  • 3
  • 9
  • Is there a way to make this more scalable for different get requests and pages etc? – lmpclk Feb 06 '18 at 12:21
  • Yes, you can write custom router which will parse and resolve HTTP query. The algorithm is about such: 1. get http query 2.parse it 3.resolve to needed action. – Nikita Feb 06 '18 at 12:25
  • Very wide theme) Example of attractive routing you can get in modern frameworks. [as Laravel](https://laravel.com/docs/5.5/routing) – Nikita Feb 06 '18 at 12:26