formadmirer
asked on
Examine Part of URL
Hello all. I'm trying to figure out how to parse part of a url to determine the associated directory. For example, the URL is:
http://mywebsite.com/admin/something.php
-or-
http://mywebsite.com/user/something.php
I need to determine if the URL contains 'admin' or 'user'.
PHP 5.4
Thanks!
http://mywebsite.com/admin/something.php
-or-
http://mywebsite.com/user/something.php
I need to determine if the URL contains 'admin' or 'user'.
PHP 5.4
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can find this information in $_SERVER["HTTP_HOST"] and $_SERVER["REQUEST_URI"]. The HTTP_HOST will be mywebsite.com and the REQUEST_URI will be /admin/something.php
But that said, whenever I see a question like this, I wonder about the back-story. Why does your PHP script need to know this information? There is almost always some reason that can build a security flaw into your design.
But that said, whenever I see a question like this, I wonder about the back-story. Why does your PHP script need to know this information? There is almost always some reason that can build a security flaw into your design.
ASKER
This worked perfect for my needs - thank you!
http://www.php.net/parse_url