WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using echo network_site_url(); to place the url of each site in a WordPress MultiSite installation. This outputs http://site.com/ How do I remove the http:// and trailing slash?


share|improve this question
up vote 4 down vote accepted
preg_replace("~^(?:f|ht)tps?://~i", '', $url);

Replaces http https and FTP in string $url

share|improve this answer
Thanks. Can you explain further how to implement that in my code? – AHCo Dec 18 '11 at 7:50
echo preg_replace("~^(?:f|ht)tps?://~i", '', network_site_url()); – chrisguitarguy Dec 18 '11 at 7:57
@ChristopherDavis Brilliant! Thank you! – AHCo Dec 18 '11 at 23:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.