|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
let's imaging we have the following thing : www.mywebsite.com/company/index.php www.mywebsite.com/company/profile.php www.mywebsite.com/services/index.php how can i detect in which address am i ? for example how to retrieve www.mywebsite.com/services or www.mywebsite.com/company -- Alain ------------------------------------ Windows XP SP2 PostgreSQL 8.2.4 / MS SQL server 2005 Apache 2.2.4 PHP 5.2.4 C# 2005-2008 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Get the various parts from the $_SERVER superglobal variable:
1) scheme (e.g. http://) from $_SERVER['HTTPS'] (https if "on") 2) host:port (e.g. bucksvsbytes.com) from $_SERVER['HTTP_HOST'] 3) /path/page?query part (e.g. /catalog/index.php?pid=444) from $_SERVER['REQUEST_URI'] John Gunther Alain Roger wrote: > Hi, > > let's imaging we have the following thing : > > www.mywebsite.com/company/index.php > www.mywebsite.com/company/profile.php > www.mywebsite.com/services/index.php > > how can i detect in which address am i ? > > for example how to retrieve www.mywebsite.com/services or > www.mywebsite.com/company > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jan 5, 2008 12:06 PM, Alain Roger <raf.news@gmail.com> wrote:
> Hi, > > let's imaging we have the following thing : > > www.mywebsite.com/company/index.php > www.mywebsite.com/company/profile.php > www.mywebsite.com/services/index.php > > how can i detect in which address am i ? > > for example how to retrieve www.mywebsite.com/services or > www.mywebsite.com/company <? preg_match('/\/(.*)\//',$_SERVER['REQUEST_URI'],$match); echo $match[1]; ?> -- Daniel P. Brown [Phone Numbers Go Here!] [They're Hidden From View!] If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Alain Roger escreveu:
> Hi, > > let's imaging we have the following thing : > > www.mywebsite.com/company/index.php > www.mywebsite.com/company/profile.php > www.mywebsite.com/services/index.php > > how can i detect in which address am i ? > > for example how to retrieve www.mywebsite.com/services or > www.mywebsite.com/company > There are many methods like using the $_SERVER variable (auto generated) $_SERVER['REQUEST_URI'] or $_SERVER['SCRIPT_NAME'] Try this and tell us ![]() Breno |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
At 6:06 PM +0100 1/5/08, Alain Roger wrote:
>Hi, > >let's imaging we have the following thing : > >www.mywebsite.com/company/index.php >www.mywebsite.com/company/profile.php >www.mywebsite.com/services/index.php > >how can i detect in which address am i ? > >for example how to retrieve www.mywebsite.com/services or >www.mywebsite.com/company > >-- >Alain ------------------------------------ Allan: I think I see where you are going with this -- try this: http://sperling.com/examples/smart-menu/ Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
John Gunther wrote:
> Get the various parts from the $_SERVER superglobal variable: > 1) scheme (e.g. http://) from $_SERVER['HTTPS'] (https if "on") > 2) host:port (e.g. bucksvsbytes.com) from $_SERVER['HTTP_HOST'] > 3) /path/page?query part (e.g. /catalog/index.php?pid=444) from > $_SERVER['REQUEST_URI'] There's also $_SERVER['PHP_SELF']. Probably others too. Simply: <?php print_r($_SERVER); ?> This will show you what's available to you. -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Desk software that can cut the cost of online support ** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS ** |
|
![]() |
| Outils de la discussion | |
|
|