如何在web2py和google appengine中缩短网址 [英] how to make url shorter in web2py and google appengine

查看:238
本文介绍了如何在web2py和google appengine中缩短网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图缩短网址。例如,更改

  www.mydomainname.com/myapp/default/mypage 

www.mydomainname.com/mypage



我在web2py文件夹下的routes.py中添加以下代码:

  routes_out =(
( '。*:/ sevenpeng / default(?P< any>。*)','\g< any>),)

但这不起作用。该网址仍然显示 www.mydomain.com/default/mypage
我缺少什么?



另一个问题,我部署我的网站谷歌appengine,当我输入www.mydomainname.com,它指向正确的网页,地址仍然是www.mydomainname.com。但是,当我直接键入mydomainname.com到浏览器中时,地址变为1.myapp.appspot.com/myapp。如何解决这个问题?



谢谢 解决方案

最简单的方法要从URL中删除应用程序名称和默认控制器,请使用

  routers = dict(
BASE =nofollow>基于参数的重写系统
, dict(
default_application ='myapp',
default_controller ='default',
default_function ='index',
),

以上内容位于/web2py/routes.py中。请注意,基于参数的系统不能与基于模式的系统

I've been trying to make URLs shorter. For example, change

www.mydomainname.com/myapp/default/mypage

to www.mydomainname.com/mypage

I add the following code in routes.py under the web2py folder:

routes_out=(
    ('.*:/sevenpeng/default(?P<any>.*)', '\g<any>'),)

But this didn't work. The url still shows www.mydomain.com/default/mypage Am i missing something?

Another problem, I deployed my website on google appengine, when I typed www.mydomainname.com, it directs to the right page, and the address is still www.mydomainname.com. However, when i typed directly mydomainname.com into browser, the address changes to 1.myapp.appspot.com/myapp. How can I fix this?

Thanks

解决方案

The easiest way to remove the app name and the "default" controller from the URL is to use the parameter-based rewrite system, as follows:

routers = dict(
    BASE = dict(
        default_application = 'myapp',
        default_controller = 'default',
        default_function = 'index',
    ),
)

The above goes in /web2py/routes.py. Note, the parameter-based system cannot be mixed with the pattern-based system.

这篇关于如何在web2py和google appengine中缩短网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆