2016-07-20 33 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>