Trimming Last Path or Page of a URL

Stolen from stackoverflow

 

If URLs have a slash at the end of them, then use this formula to remove the final slash first

=LEFT(A16, FIND(CHAR(1), SUBSTITUTE(A16, "/", CHAR(1), LEN(A16)-LEN(SUBSTITUTE(A16, "/", ""))))-1)

Then use the formula again on the URL with the final slash removed.

Removing everything after last trailing slash excel
Use Formula on URL twice if there is a trailing slash / at the end of it.