I'm trying to check for /index.[ php | htm | html | asp ], etc. (basically any wildcard suffix)
or simply "/"
to convert a canonical URL such as http://www.example.com/index.php or http://www.example.com/ to just http://www.example.com so I can just use one consistent PHP variable in my canonicalmeta tag throughout all the pages on my site.
I dont want the script to effect URLs that are NOT homepages such as http://www.example.com/page.php
REGEX preferred, but not necessary.
I'm working from the variable $current_Webpage_Complete_URL_Address in "domain_info.php" from this script: http://www.perfecterrordocs.com
I want to use just one PHP variable, formed from modifying $current_Webpage_Complete_URL_Address, if that makes any sense.
Please ask for further clarification, if neccassary.
Edit: Also, I want the newly formed variable to be named
$current_Webpage_Canonical_URL_Address
Edit(2): I just ran into another problem. Even when I do find a match with preg_match how do I remove that particular ending sub-string?
Final Answer (Works Perfectly!!):
$current_Webpage_Canonical_URL_Address = preg_replace('/((\\index)\.[a-z]+)$/', '', $current_Webpage_Complete_URL_Address);
$current_Webpage_Canonical_URL_Address = preg_replace('/\/$/', '', $current_Webpage_Canonical_URL_Address);