我在使用BlueHost的部署我的Django应用到生产服务器的过程,但一直看到我的网站的404页。这个问题似乎是我的URL配置。当我键入 http://www.example.com/到我的浏览器,我收到以下内容:
I'm in the process of deploying my Django app to a production server using Bluehost but keep seeing my site's 404 page. The issue seems to be my URL configuration. When I type http://www.example.com/ into my browser I receive the following :
Request URL: http://www.example.com/public_html/
^main/
^admin/
^accounts/
^media/(?P<path>.*)$
etc..
The current URL, public_html/, didn't match any of these
的public_html /会自动添加到我的网址的结尾,我想消除的public_html /完全是这样我的URL模式将正常工作。例如
public_html/ is automatically added to the end of my URL I would like to eliminate the public_html/ entirely so my URL pattern will work as expected. For example
Request URL: http://www.example.com/
这将然后重定向到
Which would then redirect to
Request URL: http://www.example.com/main/
我怎么会去从 http://www.example.com/public_html/来 http://www.example.com/ 的?
我的FCGI文件:
AddHandler fcgid-script .fcgi
RewriteEngine on
RewriteBase /
RewriteRule ^(media/.*)$ - [L]
RewriteRule ^(adminmedia/.*)$ - [L]
RewriteCond %{REQUEST_URI} !(cgi-bin/mysite.fcgi)
RewriteRule ^(.*)$ cgi-bin/mysite.fcgi/$1 [L]
我的.htaccess文件:
My .htaccess file:
#!/home/username/python/bin/python
import sys, os
sys.path.insert(0, "/home/username/python")
sys.path.insert(13, "/home/username/MySite")
os.environ['DJANGO_SETTINGS_MODULE'] = 'MySite.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
有没有一种可能性,这可能是一个问题,在我的文件位于我的服务器上?如果任何人之前,我将不胜AP preciate一些建议经历过这种问题。谢谢!
Is there a possibility this could be an issue with where my files are located on my server? If anyone has experienced this kind of issue before I would greatly appreciate some advice. Thanks!
您需要定义以下URL您的urls.py,
You have to define following url in your urls.py,
url(r'^$', 'views.home', name='home')
url(r'^main/$', 'views.main', name='main')
然后在views.py
then in views.py
def home(request):
return HttpResponseRedirect('/main/')
def main(request):
#some code here.