homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

Meta Refresh Question
Another way?

 5:13 am on Feb 21, 2003 (gmt 0)

Hi All-

Many people are coming to my site, leaving off the 'www' part of the URL. To work in appliance with a script that I have, I need them to come through the www.mysite.com domain. So, I need a way for the page to redirect to www.mysite.com when they type in just mysite.com.

Everything I try creates a loop and crashes the browser. That is:

<meta-http-equiv="refresh" content="0; url=http://www.mysite.com/"> or PHP,
header("Location: [mysite.com")......]

Both create loops. Any help is appreciated!



 5:19 am on Feb 21, 2003 (gmt 0)


You could use a server-side redirect. Try a WebmasterWorld site search for "301 redirect" and you'll finds tons of info. You'll have to sort the threads out by server type to get the right method for your server.



 5:20 am on Feb 21, 2003 (gmt 0)

Technically aren't www.yoursite.com and yoursite.com the same thing?

I found a few neat ones on google, type in "better redirect script" or something along those lines and you should come across some good ones.


 5:35 am on Feb 21, 2003 (gmt 0)

Excellent, thanks for your help...

Yeah they're the same, but for some reason my scripts become disabled without the full domain. Strange to me.


 5:41 am on Feb 21, 2003 (gmt 0)

www.example.com is a subdomain of example.com, and is not the same thing - unless your DNS zone file is set up to treat them the same (admittedly, many are).

Check out the server-side redirect threads - more efficient than scripting and it's a "set and forget."



 4:25 am on Feb 23, 2003 (gmt 0)

If you're running apache and mod_rewrite is installed the following should work:

RewriteEngine On
RewriteCond %{HTTP_HOST}!^www\.example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


 4:57 am on Feb 23, 2003 (gmt 0)

You'll need a space in front of the "!" for this to work. The WebmasterWorld posting routine deletes these spaces.

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved