Redirect from naked domain preserving full path

1,403 views
Skip to first unread message

Giacinto

unread,
Mar 28, 2011, 6:06:13 PM3/28/11
to google-a...@googlegroups.com
Hello, 
I have a big problem that I looked, is the same problem of a number of appengine users. I googled about the problem but I did not found any valid solution. I registered a domain for my application using Godaddy through appegine control panel (Application Settings -> Add Domain... etc...). If I go on mydomain.com/foo/bar it redirects to www.mydomain.com without /foo/bar. Please there is a way to make mydomain.com redirects on www.mydomain.com/foo/bar ? I use Django with Django nonrel.

Thank you.

Sahid Orentino Ferdjaoui

unread,
Mar 29, 2011, 12:14:41 PM3/29/11
to google-a...@googlegroups.com
Hello,

You need to remove the redirection mydomain.com/ -> www.mydomain.com in Godaddy and use a middelware.

An example:

class SubDomainMiddleware(object):
    def process_request(self, request):
        bits = request.get_host().split('.')
        subdomain = bits[0]
if subdomain <> "www":
            return HttpResponsePermanentRedirect"http://www.mydomain.com/%s" % (request.get_full_path()))

Message has been deleted

Giacinto

unread,
Mar 29, 2011, 4:29:44 PM3/29/11
to google-a...@googlegroups.com
Thank you for your reply, I tried your solution but it doesn't work. 
I have no forward setted up on GoDaddy, but google appengine not supports naked domain. In Google App control panel there is a costraint that requires www as a target for the naked domain. Maybe for this reason request.get_full_path() returns always "/" . Any other ideas?

Robert Kluin

unread,
Mar 30, 2011, 12:36:06 AM3/30/11
to google-a...@googlegroups.com
Hi Giacinto,
You've got something wrong with your forwarding settings at godaddy.
I've got forwarding setup for some domains at godaddy, it should be
set to "Forward Only" (I use "I am only temporarily forwarding my
domain.") It works fine, and correctly forwards with the path.

Robert

> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>

Giacinto

unread,
Mar 30, 2011, 1:23:52 AM3/30/11
to google-a...@googlegroups.com
Hi Robert, I tried to forward domain through GoDaddy but i setted "I am permanently forwarding my domain", however just now i tried your configuration and i forwarded through GoDaddy using "forward only" and "I am only temporary forwarding my domain" and it doesn't work. I lost full path in redirect from the address bar and from the request.get_full_path() .

Robert Kluin

unread,
Mar 30, 2011, 11:40:28 AM3/30/11
to google-a...@googlegroups.com
Hi,
I just double checked it again, it works fine for me. Perhaps you
need to give more time for the DNS settings to propagate? Have you
tried from another browser?

In my "Domain Manager" I see:
Forwarding: On (Last Update 1/14/2011)
Forward Only
http://www.exdomain.com

When I go to:
http://exdomain.com/test/path

I am redirected to:
http://www.exdomain.com/test/path

When I check the response from godaddy's server for the request above:
Cache-Control:private
Content-Length:153
Content-Type:text/html; charset=utf-8
Date:Wed, 30 Mar 2011 15:37:40 GMT
Location:http://www.exdomain.com/test/path
Server:Microsoft-IIS/6.0
X-AspNet-Version:2.0.50727
X-Powered-By:ASP.NET


Not too fond of the IIS / ASP.Net part, but it seems to be getting
the job done.


Robert

Jeff Schnitzer

unread,
Mar 30, 2011, 12:36:07 PM3/30/11
to google-a...@googlegroups.com
I just thought I would point out that sometime within the last several
months (possibly quite a few, I don't look often) Google added the
ability to automatically redirect your naked domains to www (or
whatever).

There's a setting in the Google Apps control panel.

Jeff

Giacinto

unread,
Mar 30, 2011, 2:31:32 PM3/30/11
to google-a...@googlegroups.com
Well, i solved the problem! None of the previous solutions is really the good solution, or better, none is complete. The real problem of the lost request's full path is the google autosetting for www redirect! 

Robert helped me to find the way! Maybe to you Robert all is correct because you did not bought your domain using appengine control panel. Maybe you bought your domain directly from GoDaddy.

I share here my solution. GoDaddy's redirect works fine, and if you want to preserve the famous full path you have to enable redirect from GoDaddy domain manager! I think that permanent (301) redirect is better the temporary (302), but this is another story...

If you registered your domain from appengine interface, google have automagically setted your "A records" in order to make working his www redirect! 
This is the problem! 
You have to delete all of your "A records" from the DNS settings in GoDaddy's domain manager, and then enable the naked domain redirect to www subdomain through GoDaddy, using only the GoDaddy's domain manger interface. 

GoDaddy will automatically sets your "A record" in order to make working his redirect. Wait a few minutes for DNS propagation and now your domain will be redirect from the naked to www preserving request's full path!!

I thank you all! 

Robert Kluin

unread,
Mar 30, 2011, 3:02:41 PM3/30/11
to google-a...@googlegroups.com
Yep, that would explain it. Thanks for the info Jeff and Giacinto,
none of the domains I'm an admin on have an option (that I can find)
to redirect from the naked domain. I've never bought a domain through
Google, perhaps that is specific to domains purchased through Google?

Robert

Giacinto

unread,
Mar 30, 2011, 3:14:12 PM3/30/11
to google-a...@googlegroups.com
Yes, is right, Robert. I think that GoDaddy's domain manager is not the same if you buy domain from google. If you buy domain from googleappengine it enables Google App services for that domain. I think that domain management is a bit different from the usual in this case.

James Broberg

unread,
Mar 30, 2011, 6:45:41 PM3/30/11
to google-a...@googlegroups.com
I noticed that too. Is this the naked domain support we have been
waiting for, or some sort of workaround?

Mars

unread,
Mar 31, 2011, 11:45:04 PM3/31/11
to Google App Engine
Actually in order for naked domain transfer to work, you must have the
A record @ points to "64.202.189.170" on GoDaddy. This is supposed to
be the default behavior when you check "Update my DNS settings to
support this change. (Recommended)" in the domain manager but somehow
didn't happen to me. Took me a while to figure that one out.

Cheers,

Mars

Thomas Wiradikusuma

unread,
Apr 2, 2011, 12:13:04 AM4/2/11
to Google App Engine
Hi Giacinto,

I'm having exactly the same problem. Can you get into more detail
(step-by-step, starting from https://www.google.com/a/cpanel/MYDOMAIN/DomainSettingsDomains
probably?) on how you get it done? I understand your post, but I'm
afraid I might click/delete the wrong stuff.

roberto.cr

unread,
Apr 8, 2011, 9:29:22 PM4/8/11
to Google App Engine
I'm having the same problem!

I've set (under google apps cpanel DomainSettingsDomains) google apps
to redirect mydomain.com to app.mydomain.com (because appengine
doesn't allow for naked domains anymore)
Then I've set (under google apps cpanel AppEngineServiceSettings) app
engine to listen to *.mydomain.com (yes, you can set the * wildcard
there now)
This worked almost perfectly, but the only thing off is actually the
most important:

mydomain.com would redirect to app.mydomain.com
userinput.mydomain.com would keep the userinput and load my regular
app.mydomain.com (as described in my app.yaml, having my app to treat
"userinput": in Python's webapp framework you can access this with
self.request.headers['Host'] )
userinput.mydomain.com/login would keep the url but behave like
app.mydomain.com/login (as expected) while still being able to read
"userinput"
BUT mydomain.com/login would NOT redirect to app.mydomain.com/login !
it simply redirects to app.mydomain.com ignoring the full path!

the problem seems to be the way google redirects my naked domain. it
ignores the full path. I guess it's not just me, is it?

so you are saying the solution really involves setting everything up
on godaddy ?
(in my case hostgator. I bought a .to domain, set the NS to my regular
hostgator account and setting all DNS settings there.)

On Apr 2, 1:13 am, Thomas Wiradikusuma <wiradikus...@gmail.com> wrote:
> Hi Giacinto,
>
> I'm having exactly the same problem. Can you get into more detail
> (step-by-step, starting fromhttps://www.google.com/a/cpanel/MYDOMAIN/DomainSettingsDomains

roberto.cr

unread,
Apr 9, 2011, 4:36:55 AM4/9/11
to Google App Engine
TL;DR

Google is not redirecting my naked domain preserving full path.
Examples:
mydomain.com -> app.mydomain.com CORRECT
mydomain.com/login -> app.mydomain.com WRONG ( should've pointed to
app.mydomain.com/login )
john.mydomain.com/login -> john.mydomain.com/login CORRECT

Does this happen to *everyone* ??? How come there's not much info
about it on this discussion group ?
How are people solving this ?

Robert Kluin

unread,
Apr 9, 2011, 2:59:54 PM4/9/11
to google-a...@googlegroups.com
If you read back through this entire thread you'll see some discussion
on that issue. Perhaps people are generally using some other
forwarding service.


Robert

roberto.cr

unread,
Apr 11, 2011, 1:46:18 AM4/11/11
to Google App Engine
a newbie trying to deal with DNS settings is a mess, plus it's boring
to wait and see if it worked, so I decided to come back here and tell
more detailed steps on how to solve this before google does ;)

Google Apps tells you to insert 4 A records pointing to 4 google IPs.
How to reach it: Domain Settings, Domain names (
https://www.google.com/a/cpanel/mydomain.com/DomainSettingsDomains )
Then you need to set which subdomains you want to listen in
yourdomain.com and point to your appengine app. Yes, you can now set
the * wildcard (this is what I'll use for the CNAME later).
How to reach it: Dashboard, your Google App Engine project (
https://www.google.com/a/cpanel/mydomain.com/AppEngineServiceSettings?appId=myappengineid
)

Google Apps recommends you to do this on your DNS settings:
mydomain.com A -> google 4 IPs
* CNAME -> ghs.google.com

But I've changed it to (replace 'app' with your desired subdomain):
app.mydomain.com A -> google 4 IPs
* CNAME -> ghs.google.com
app A -> your regular hosting IP

then, on your regular hosting (hostgator in my case, godaddy for
others), create a .htaccess on the root with this content:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ "http\:\/\/app\.mydomain\.com\/$1" [R=302,L]

this way you keep google apps handling everything except the naked
mydomain redirection.
your regular hosting will be foing the naked domain redirection
preserving full path (as described in this .htaccess), redirecting it
to app.mydomain.com/full/path (and from there forward it's back on
google's hands).
it's a good way to fix this problem by yourself, until google fixes
their redirector (I've already warned about the problem on Google
Apps).
Reply all
Reply to author
Forward
Message has been deleted
0 new messages