简体   繁体   English

多个网址映射到同一功能

[英]Multiple urls mapped to same function

I have this url in my urls.py: 我的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 ? 但是具有上述两个网址会导致两个网址映射到相同的数据,这从seo角度来看是不好的。所以解决方案是将陈列室/网址重定向到陈列室/网址,但是当陈列室/指向设置时,我该如何解决这个问题应用文件夹中的网址数量?

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 如果要使其靠近django,可以使用此处的文档中提供的redirect快捷方式: 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! 否则,这更像是一个网络服务器问题,对于apache,有mod_rewrite ,您可以在其中进行301重定向,而nginx具有可以满足您的需求的rewrite指令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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