Page 1 of 1

Help Me Site Redirect

Posted: Tue Mar 31, 2009 2:56 am
by link2nayak
Hi Friends,

I create my site http://www.padcilpharma.com its host on window server.

Its open with and without www.

I want its open with only www.

My host provider told me use phc scripting for that.


How am I do that...

Help

Re: Help Me Site Redirect

Posted: Tue Mar 31, 2009 3:24 am
by requinix
1) I can't get to your site.
2) What does "open" mean? "Accessible"?
3) Never heard of PHC.

Re: Help Me Site Redirect

Posted: Tue Mar 31, 2009 4:53 am
by greyhoundcode
Take a look at $_SERVER['REQUEST_URI'] and inspect it to see if it contains the 'www' prefix. If it doesn't, use header() to redirect.

Re: Help Me Site Redirect

Posted: Tue Mar 31, 2009 8:39 am
by LanceEh
Why not just use htaccess?

Re: Help Me Site Redirect

Posted: Wed Apr 01, 2009 5:31 am
by greyhoundcode
LanceEh wrote:Why not just use htaccess?
I assuming he isn't allowed to do this with his shared hosting account - "My host provider told me use phc scripting for that." (If phc is indeed PHP!) - though I guess that is an easier way to do it.
link2nayak wrote:
greyhoundcode wrote:Take a look at $_SERVER['REQUEST_URI'] and inspect it to see if it contains the 'www' prefix. If it doesn't, use header() to redirect.
I can't understand you.
You could have replied in this forum you know, rather than by PM. Not as if we're discussing state secrets or anything :wink:

Anyway, assuming you can't sort it via .htaccess like LanceEh says, what I was getting at was you could look at the contents of $_SERVER['REQUEST_URI'] (if this array element is accessible on your setup) and see if 'www.' is present in the address.

If it isn't, you can redirect the user using the header() function. If you're still unsure, take a look at the PHP manual's info on the $_SERVER array and its entry on the header() function.