how to make url shorter in web2py and google appengine

无人久伴 提交于 2019-12-21 21:33:05

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8671936/how-to-make-url-shorter-in-web2py-and-google-appengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!