[英]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. 我正在使用colorurl.com网站,我需要用户能够输入colorurl.com/00ff00(或其中的一些变体),并查看正确的页面。 However, with the naked domain issue, users who type in colorurl.com/somepath will instead be redirected to www.colorurl.com/. 但是,对于裸域问题,输入colorurl.com/somepath的用户将被重定向到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?) 有没有办法在python中检测到这一点,然后将用户重定向到他们想去的地方(添加了www?)
EDIT: 编辑:
Clarification: In my webhost's configuration I have colorurl.com forward to www.colorurl.com. 澄清:在我的webhost配置中,我将colorurl.com转发到www.colorurl.com。 They do not support keeping the path (1and1). 它们不支持保留路径(1和1)。 I have to detect the previous path and redirect users to it. 我必须检测上一个路径并将用户重定向到它。
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.*: 我在这种情况下要做的是在你的裸域建立一个小站点,它只包含一个.htaccess文件,它将路径重定向到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.*; 您需要使用第三方站点进行重定向到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; Godaddy的服务(通过域名注册免费提供)将foo.com/bar转发到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. 我无法谈论其他人的能力,但在我看来,任何一个不这样做的人都会被打破。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.