hello I would like to remove all filenames from my url :
http://website.com/folder1/folder2/filename.php
here is what I have tried :
$file_info = pathinfo('http://website.com/folder1/folder2/filename.php');
echo $file_info['dirname'];
outputs http://website.com/folder1/folder2/ wich is what I want , but when I try this :
$file_info = pathinfo('http://website.com/folder1/folder2/');
echo $file_info['dirname'];
it outputs http://website.com/folder1/.
now what I want is if the url contains a filename then it gets removed , and if url has only folders then do nothing .
(I don't want to use .htaccess for this)