开发者

Google App Engine - Naked Domain Path Redirect in Python

I'm working on a site, colorurl.com, and I need users to be able to type in colorurl.com/00ff00 (or some variation of that), and see the correct page. However, with the naked domain issue, users who type in colorurl.com/somepath will instead be redirected to www.colorurl.com/.

Is there a way to detect this in python, and then redirect the user to where they 开发者_开发百科meant to go (With the www. added?)

EDIT:

Clarification: In my webhost's configuration I have colorurl.com forward to www.colorurl.com. They do not support keeping the path (1and1). I have to detect the previous path and redirect users to it.

  1. User goes to colorurl.com/path
  2. User is redirected to www.colorurl.com
  3. App needs to detect what the path was.
  4. App sends user to www.colorurl.com/path


What I'd do in this scenario is set up a small site at your naked domain which consists of just a .htaccess file which redirects path and all to www.*:

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^colorurl.com [NC] 
RewriteRule ^(.*)$ http://www.colorurl.com/$1 [L,R=301]


You need to use a third-party site to do the redirection to www.*; many registrars offer this service. Godaddy's service (which is even free with domain registration) forwards foo.com/bar to www.foo.com/bar; I can't speak to the capabilities of the others but it seems to me that any one that doesn't behave this way is broken.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜