I was looking into this issue but I couldn’t find any solid answers for this specific purpose. Let’s say I have a URL of…
http://mysite.com/stuff/index.php?search=my+search
How can I grab this URL and remove index.php?search=my+search from it so it would just be http://mysite.com/stuff/ ? Basically I just want to grab the parent URL without a filename or get variables… No matter what the URL (so I don’t have to customize the function for every page I want to use it on)
So for an additional example, if it were just…
http://mysite.com/silly.php?hello=ahoy
I would just want to return the root of http://mysite.com
Can anyone give me a hand in figuring this out? I’m completely lost.
Try using
lastIndexOf("/"):OR