Hi people!

I'm creating a new website using Web2py [ Version 2.0.0 (2012-06-10 
21:17:42) dev ] on GAE in a domain where previously I had a WordPress blog!

This blog has some urls like these:

http://domain.com/novo-modelo/hyundai-hb-20/
http://domain.com/carro-conceito/nanotata/testes/

In order to not lose the whole traffic to the old blog, it were transfered 
to another domain and I need to make http 301 redirects to all of his pages!

I'm using the following approach:

I catch the 404 erros and verify if the request_uri is one of the urls from 
the old blogs I need to redirect ( I have all urls taken from the 
sitemap.xml ).
This works fine, except for urls like those before, that have hyphens in 
the first "arg" as in "novo-modelo" and "carro-conceito".



I did that on routes.py:

routes_onerror = [
    (r'*/404', r'/init/httpcodes/cod404')
]


And in the function cod404, I verify the URL and do the redirect if the URL 
is from the old blog!


When the URL is 

http://domain.com/novo-modelo/hyundai-hb-20/

I got the error: "invalid request"... and it is not treated as 404!

What can I do to allow web2py understand this URL as 404?


I tryed map_hyphen = True but had no success!

This are the some other informations on my router.py.



default_router = dict(
    default_application = 'init',
        applications = 'ALL',
    default_controller = 'default',
        controllers = 'DEFAULT',
    default_function = 'index',
        functions = None,
    default_language = None,
        languages = None,
    root_static = ['favicon.ico', 'robots.txt'],
    domains = None,
    map_hyphen = False,
    acfe_match = r'\w+$',              # legal app/ctlr/fcn/ext
    file_match = r'(\w+[-=./]?)+$',    # legal file (path) name
    args_match = r'([\w@ -]+[=.]?)+$', # legal arg in args
)






#  This simple router set overrides only the default application name,
#  but provides full rewrite functionality.

routers = dict(

    # base router
    BASE = dict(
        default_application = 'init',        
    ),
)


-- 



Reply via email to