If you are trying to create a login system with redirection you need to use the HTTP_REFERER header to find out where the user came from so you can send him back there. The best way to do this is, in your login form use something like this:
Please note that some ISPs, browsers or proxies will strip out the referer header, so you can't rely on it to work perfectly for every user. If you use an if statement to check whether the header exists or not, you can send those users back to the homepage or whatever.
EDIT
If you're looking to use $_SERVER['REQUEST_URI'] it should be set to the pretty URL after a rewrite if you're running Apache. If you're running IIS, in which case you need to check for $_SERVER['X_HTTP_ORIGINAL_URL']. Something like this:
If you are trying to create a login system with redirection you need to use the HTTP_REFERER header to find out where the user came from so you can send him back there. The best way to do this is, in your login form use something like this:
Please note that some ISPs, browsers or proxies will strip out the referer header, so you can't rely on it to work perfectly for every user. If you use an if statement to check whether the header exists or not, you can send those users back to the homepage or whatever.
EDIT
If you're looking to use $_SERVER['REQUEST_URI'] it should be set to the pretty URL after a rewrite if you're running Apache. If you're running IIS, in which case you need to check for $_SERVER['X_HTTP_ORIGINAL_URL']. Something like this:
and