Jump to content

need help of www to non www in php


blacktiger786

Recommended Posts

i want create some code i don't know what i do can you help me

if i have domain like

http://www.domain.com

www.domain.com

 

 i want run code which remove www from this domain this not for one domain i want when any domain come with www its remove www and

show without www like

http://domain.com

and if any domain come without www it let it

what i do please help me?

Link to comment
https://forums.phpfreaks.com/topic/290205-need-help-of-www-to-non-www-in-php/
Share on other sites

Just to clarify, are you trying to redirect visitors who go to "www.domain.com" to "domain.com"? Or are you just looking to manipulate a string?

 

For what it's worth, PHP has a built-in function for parsing URLs:

http://php.net/manual/en/function.parse-url.php

 

You could also look at replacing the "www." part using str_replace(). Just be aware that this will replace all occurrences of "www."

http://php.net/manual/en/function.str-replace.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.