2016-07-20 42 views
0

我有以下的.htaccess文件 -隐藏fcgi的脚本文件名主持FastCGI的和Apache

AddHandler fcgid-script .fcgi 
DirectoryIndex index.fcgi 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.fcgi$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.fcgi/$1 [L] 
</IfModule> 

及以下index.fcgi文件:

#!/home/username/mydjango/bin/python 
    import os 
    import sys 

    from flup.server.fcgi import WSGIServer 
    from django.core.wsgi import get_wsgi_application 

    sys.path.insert(0, "/home/username/mydjango") 
    os.environ['DJANGO_SETTINGS_MODULE'] = "testproject.settings" 

    WSGIServer(get_wsgi_application()).run() 

Django的应用程序成功运行,但插入的URL“index.fcgi”像这个 -

www.example.com/index.fcgi/admin,而不是www.example.com/admin

我怎样才能从网址中去除脚本的名称?

我想这里的指示 - http://flask.pocoo.org/docs/0.10/deploying/fastcgi/

但它是瓶,我不能让它运行Django的。

P.S - 我与服务器没有根访问共享的托管计划。

回答

1

我只是在我的.htaccess文件中加入这一点。这足以用于隐藏URL中的index.fcgi。

<IfModule mod_fcgid.c> 
    AddHandler fcgid-script .fcgi 
    <Files ~ (\.fcgi)> 
     SetHandler fcgid-script 
     Options +FollowSymLinks +ExecCGI 
    </Files> 
</IfModule> 

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L] 
</IfModule>