Add / remove a port number to/from a URL with REGEX in PHP
I've searched but was unable to find an existing regex function. Has anybody done this before?
I wish to add a port number, or remove a potantially existing one from a url in php. To use in some functions which translate a given url to the secure one, unsecure one,开发者_运维知识库 etc.
Now I need a second SSL secured site on the server so I need to dynamically add a port number while converting http to https, and remove any port number while converting from https to http.
Thanks, Duck
Instead of a regex, you can use the built-in parse_url function to break apart and reassemble the URL to match your requirements.
精彩评论