0

I have an application with a filenames a bit long.

I would like to remove the name of the file and extension of the php files and only show my domain or server name.
Example: this is what i have:
www.example.com/dir/my_long_file.php

This is what i need.

www.example.com

4
Contributors
4
Replies
27
Views
4 Years
Discussion Span
Last Post by tutorials.scripts
0

This code is for localhost:

$site_name  =   $_SERVER['REQUEST_URI'];
$site_name  =   explode('/', $site_name);
echo $site_name[1];

And this is for cloud server:

function get_root_domain(){
    $url    =   strtolower($_SERVER['HTTP_HOST']);
    $url    =   ereg_replace('www\.', '', $url);
    $url    =   parse_url($url);

    return (!empty($url['host'])) ? $url['host'] : $url['path'];
}

echo get_root_domain();

Edited by chayassongi

0

Thank you for the reply.
But the idea is not to get the host name. But to replace the browser information such that in the browser you can read only www.example.com.

0

Is this what you need? how about bookmarking certain pages? If all pages share the same url?

This can be done with sessions, but it's a bit awkward. I may be wrong.

-1
$url = $_SERVER['REQUEST_URI'];
$explode_url = explode('/', $site_name);
echo $explode_url[1];

Click Here

Edited by tutorials.scripts: Some Changes

Votes + Comments
copy of chayassongi's post
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.