开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜