I am trying to get the value after the /
in a URL in PHP.
I have tried using $_GET['va']
, but this only works for the following,
http://localhost:8080/default?va=xxx
What I'm trying to get is this,
How do I get the xxx
value after a /
in PHP.
Any help is greatly appreciated.
Edit
Thanks to everyone who answered, I wasn't very clear in stating what I wanted. It appears what I was looking for is known as a pretty URL or a clean URL.
I solved this by following Pedro Amaral Couto's answer.
Here is what I did;
I modified my .htaccess
file on my Apache server, and added the following code.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)$ default.php?page=$1
RewriteRule ^([a-zA-Z0-9]+)/$ default.php?page=$1
Then I modified my default.php
file to GET ['page']
<?php
echo $_GET['page'];
?>
And it returned the value after the "/".