Welcome to WebmasterWorld Guest from 54.145.209.34

Forum Moderators: brotherhood of lan & mack

Meta Refresh Question

Another way?

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

WebmasterWorld Senior Member 10+ Year Member



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)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



madcat,

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.

HTH,
Jim

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

10+ Year Member



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)

WebmasterWorld Senior Member 10+ Year Member



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)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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."

Jim

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

10+ Year Member



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)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month