M
M
Mikhail Lebedev2022-04-15 23:15:08
PHP
Mikhail Lebedev, 2022-04-15 23:15:08

Get full url to folder?

How to get full url in php to folder
Example:

$url = ((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];


displays the full URL with the file https://site.ru/folder/dex/index.php

and you need https://site.ru/folder/dex/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
N, 2022-04-15
@zaza41rus

<?php

$url = 'https://site.ru/folder/dex/index.php';

$url_dirname = dirname($url);

print_r($url_dirname); // https://site.ru/folder/dex

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question