每当我去{$ mydomain} / admin时,我都会被重定向到{$ mydomain} / admin / admin /。此外,如果我输入了错误的密码,我会被重定向到{$ mydomain} / admin / admin / admin / admin /,其中404错误页面的请求URL为{$ mydomain} / admin / admin / admin / admin /管理/管理/管理/管理/.
这是我的主要urls.py文件:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
# include applications
urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('my_site.urls')),
)
这是my_site.urls:
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from my_site import views
urlpatterns = patterns('',
url(r'^$', views.index, name="index"),
url(r'^stuffIMade', views.stuffIMade, name="stuffIMade"),
)
我已经尝试过运行开发服务器,而且我没有让这条奇怪的路由重复行为,所以我怀疑问题出在我的nginx conf上,这是:
server {
server_name .{$mydomain};
root /<root_path>/public_html;
access_log /var/log/nginx/{$mydomain}.access.log;
error_log /var/log/nginx/{$mydomain}.error.log;
# fast cgi parameters
location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:8080;
}
# These blocks will catch static file requests, such as images, css, js
location /public/ {
expires 30d;
}
location /css/ { # css_ROOT
expires 30d;
}
location /js/ { # js_ROOT
expires 30d;
}
location /fonts/ { # fonts_ROOT
expires 30d;
}
# remove the robots line if you want to use wordpress' virtual robots.txt
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
# this prevents hidden files (beginning with a period) from being served
location ~ /\. {
access_log off;
log_not_found off;
}
}
任何人都可以帮我弄清楚发生了什么吗?
编辑:有人建议添加
FORCE_SCRIPT_NAME = ""
到我的settings.py文件。不知何故,这有效,所以问题现在变成了#34;为什么脚本名称被重写&#34;?