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?

Edited by blacktiger786
Link to comment
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

Edited by cyberRobot
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.