简体   繁体   中英

Multiple urls mapped to same function

I have this url in my urls.py:

url(r'^showrooms/', include('apps.showrooms.urls')),

and i want to have another url like this(ie w/o 's' of showrooms)

url(r'^showroom/', include('apps.showrooms.urls')),

but having two urls like above results in two urls mapping to same data which is not good from seo perspective.So the solution is to redirect showroom/ urls to showrooms/ urls, but how do i get to this as showrooms/ is pointing to set of urls in apps folder ?

If you want to keep it close to django you can use the redirect shortcut as found in the documentation here: https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect

Otherwise this is more like a webserver question, for apache there is mod_rewrite in which you can 301 redirect, and nginx has the rewrite directive which should suit your needs just fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM