PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > identify by php the path of the page
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
identify by php the path of the page

Réponse
 
LinkBack Outils de la discussion
Vieux 30/09/2007, 22h39   #1 (permalink)
artev
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut identify by php the path of the page

if I have a file myfile.php (the dir are more)

http://SITE/A/B/myfile.php

is possible insert in the page a code that write the path where it is =
http://SITE/A/B/

and also must recognize if its url change example http to https
https://SITE/A/B/myfile.php
it write
https://SITE/A/B/
  Réponse avec citation
Vieux 01/10/2007, 05h32   #2 (permalink)
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: identify by php the path of the page

artev wrote:
> if I have a file myfile.php (the dir are more)
>
> http://SITE/A/B/myfile.php
>
> is possible insert in the page a code that write the path where it is =
> http://SITE/A/B/
>
> and also must recognize if its url change example http to https
> https://SITE/A/B/myfile.php
> it write
> https://SITE/A/B/


If you use a decent web server, then you can use mod_rewrite to make the web
server load a different file than what what the browser has requested.

--

//Aho
  Réponse avec citation
Vieux 01/10/2007, 13h53   #3 (permalink)
artev
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: identify by php the path of the page

I explained better my problem (localhost in production will be NAMESITE)
If I am in http://localhost/A/test.php

I want in php a code (or function) that print:
http://localhost/A/

so it recognize automatically the url

I tested functions:
HTTP_HOST but print only localhost
SERVER_NAME but print only localhost
PHP_SELF not print all and insert also file's name (I not want)
/A/test.php

dirname($HTTP_SERVER_VARS['PHP_SELF']); not print all /A


I can write so (semplified the merge):
http:// + SERVER_NAME + dirname PHP_SELF
but remain problems that I must know when I am in https so I can change
the first part http in https;

and is better use SERVER_NAME or HTTP_HOST for recognize SITE (localhost)


is there a function that to do all?
  Réponse avec citation
Vieux 02/10/2007, 05h37   #4 (permalink)
Aaron Saray
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: identify by php the path of the page

On Oct 1, 7:53 am, artev <mailnotspa...@notspamm.nn> wrote:
> I explained better my problem (localhost in production will be NAMESITE)
> If I am inhttp://localhost/A/test.php
>
> I want in php a code (or function) that print:http://localhost/A/
>
> so it recognize automatically the url
>
> I tested functions:
> HTTP_HOST but print only localhost
> SERVER_NAME but print only localhost
> PHP_SELF not print all and insert also file's name (I not want)
> /A/test.php
>
> dirname($HTTP_SERVER_VARS['PHP_SELF']); not print all /A
>
> I can write so (semplified the merge):
> http:// + SERVER_NAME + dirname PHP_SELF
> but remain problems that I must know when I am in https so I can change
> the first part http in https;
>
> and is better use SERVER_NAME or HTTP_HOST for recognize SITE (localhost)
>
> is there a function that to do all?


What if you did this:

function getBaseUrl()
{
if (empty($_SERVER['HTTPS'])) {
//means its either not set or has no value - this will be
populated if its an SSL request
$url = 'http://';
}
else {
$url = 'https://';
}
$url .= dirname($_SERVER['REQUEST_URI']);
}

I wonder if that will work?

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h52.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09410 seconds with 12 queries