I have a url say like http://www.something.com/folder_path/contacts.php/ ( starting with http:// and ending with .php/ ). Please make sure about the slash(/) at the end of the URL.
Now I want to rewrite the URL by replacing the last element of URL i.e. /contacts.php/ to /index.php/ by matching it using regular expression.
Example code -
$url = "http://www.something.com/folder_path/contacts.php/";
$new_element = "index.php";
$regex = "#[^/.*](\.....?)/$#"; // what would be the regular expression
$new = preg_replace($regex,$new_element, $url);
The result would be http://www.something.com/folder_path/index.php/
also the path could be longer..all I need to replace is the last part of the URL. Thanks.