phpnerd Posted July 22, 2011 Share Posted July 22, 2011 Hi All, I am looking for a script in php which can check whether an url is www or non www. I have searched extensively in google but nothing conclusive has appeared. It would be of great help if someone can throw light into this. Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/ Share on other sites More sharing options...
trq Posted July 22, 2011 Share Posted July 22, 2011 This is why people should learn to think instead of wasting there time copying code from tutorials. What do you need to do? 1) Get the current url. - The $_SERVER array is the place to look. 2) Check to see if it start with the string 'www'. substr will help you do this. I'm not going to provide the code for you because it won't help you. Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1246398 Share on other sites More sharing options...
xyph Posted July 22, 2011 Share Posted July 22, 2011 Why learn to code when you can simply C+P from a tutorial? If anything goes wrong, just post in a forum like this. Eventually you'll find someone silly enough to code for you for free. Web security should be taken care of in a language as complex as PHP Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1246399 Share on other sites More sharing options...
phpnerd Posted July 25, 2011 Author Share Posted July 25, 2011 I am looking for a code to check whether an url opens with www or non www. For example http://www.example.com and http://example.com Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1246606 Share on other sites More sharing options...
trq Posted July 25, 2011 Share Posted July 25, 2011 We heard you the first time. Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1246642 Share on other sites More sharing options...
salathe Posted July 25, 2011 Share Posted July 25, 2011 Will any code given in this thread find its way into your "best scripts and software" site? Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1246710 Share on other sites More sharing options...
teynon Posted July 25, 2011 Share Posted July 25, 2011 phpnerd, the browser has a built-in PHP help manual. Press alt+f4. Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1246713 Share on other sites More sharing options...
phpnerd Posted August 1, 2011 Author Share Posted August 1, 2011 Thanx all for the response. Unfortunately I didnt got any answer which is useful. Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1250152 Share on other sites More sharing options...
trq Posted August 1, 2011 Share Posted August 1, 2011 My first reply tells you exactly what you need. Quote Link to comment https://forums.phpfreaks.com/topic/242620-check-canonical-url/#findComment-1250153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.