curl: 301 redirect

New to mod_rewrite? This is a good place to start.

curl: 301 redirect

Postby hm78 » Sat Jun 13, 2009 10:07 am

I have a www to non-www. 301 redirect at my site.

I discovered the command line tool "curl" and tested it. When I enter the URL with www, i get the following output in my console:


Code: Select all
HTTP/1.1 301 Moved Permanently
Date: Sat, 13 Jun 2009 18:03:21 GMT
Server: Apache
Location: http://example.com/
Content-Length: 225
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://example.com/">here</a>.</p>
</body></html>


What is this HTML about? I did not create it.
Are there user agents, which display this page?
hm78
 
Posts: 17
Joined: Sun Mar 04, 2007 8:26 pm

Postby richardk » Sat Jun 13, 2009 2:53 pm

What is your mod_rewrite?
Does it affect the redirect for your browser?
Does it change if your set an ErrorDocument
Code: Select all
ErrorDocument 301 /something
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby hm78 » Mon Jun 15, 2009 10:19 am

richardk wrote:What is your mod_rewrite?


Code: Select all
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]


But I don't think it has something to do with my code -- I bet this happens everywhere?

Something similar with google.com, too (when I enter google.com, without www)

hm78@pc:~$ curl http://google.com

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>


richardk wrote:Does it affect the redirect for your browser?


Nope. Everything works fine. I discovered it, when I entered "curl http://example.com" into my console.
hm78
 
Posts: 17
Joined: Sun Mar 04, 2007 8:26 pm

Postby richardk » Mon Jun 15, 2009 11:58 am

Then it's normal. It's there for user agents that do not automatically redirect when sent a redirect HTTP status code (like curl), I doubt there are any browsers that show it by default.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby hm78 » Mon Jun 15, 2009 12:04 pm

I see.

Do you know, if you can manipulate/change this "intermediate" page?

Is it depending on the server? Because my variant is different to Googles variant (so Google does not use Apache?).
hm78
 
Posts: 17
Joined: Sun Mar 04, 2007 8:26 pm

Postby richardk » Mon Jun 15, 2009 12:18 pm

Try
Code: Select all
ErrorDocument 301 /something


Is it depending on the server?

That would be the logical conclusion.

Because my variant is different to Googles variant (so Google does not use Apache?).

They have lots of different servers (software) including Google Web Server.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 104 guests

cron