I would like to be able to use jQuery $.post with url segments as follows:
www.mysite.com/stats/user1
www.mysite.com/stats
is the landing page, with this code on it:
var user = //get user1 from the url;
$.post('stats.php', {username : user}, function(results){...});
The username should be posted to a PHP backend which then does some database querying.
Is this possible? I might be able to use .htaccess to redirect users from stats/user1
to stats/
, but I don't have much experience in this area.
Many thanks in advance for your help.
EDIT
In response to Loopo's answer:
I can use .htaccess
to rewrite incoming URLs as follows:
RewriteRule ^/stats/(.*)$ stats.php?username=$1 [L]
.
This would allow me to enter a URL such as mysite.com/stats/user123
, which the server would interpret as mysite.com/stats?username=user123
In stats.php
can I then use $user = $_GET['username']
?