views:

351

answers:

1

Hey everyone,

I've made a simple site in Django. The urls I use are http::/www.example.com/nl/ and http://www.example.com/fr/.

My Django urls.py has the following line:

(r'^(?Pnl|fr)/', 'example.views.index'),

In example.views.index I check the language parameter. If it's 'nl' I show a template. If it's 'fr', I show a different template.

This worked great. Now the customer made two different urls:

http://www.dutch.com/ and http://www.french.com/

And finally I'll ask the question:

Is there a way for me to use the new urls without changing my django code? I assume I can tell apache to present the http://www.example.com/nl/ page when the user goes to http://www.dutch.com/. But how do I do this? And will django still be able to get the 'language' parameter from the url?

Thanks in advance for any answers.

+2  A: 

If you can use .htaccess files on http://www.dutch.com that you can use apache's redirect directive like so

redirectMatch 301 ^(.*)$ http://www.example.com/nl/

This will redirect all requests sent to dutch.com to example.com/nl

You could also use

redirect 301 /index.html http://www.example.com/nl/

This will redirect only "index.html" on dutch.com to example.com/nl/ (note that the first parameter is a path and can't be an URL - no http://www)

andi
This sounds it could be what I need. What will the user see however? Will the browser url change to www.example.com/nl or will it stay on dutch.com?
Also, if the index.html page has a link to '../fr/index.html', what will happen when I click it? Will it go to example.com/fr/index.html or will it give an error since I can't go one folder up on dutch.com?
yes, the URL will change to example.com/nl, so the second thing shouldn't be a problem. The user may not even notice if he is not looking at the URL. The second issue doesn't happend.
andi