0

I have following .htaccess file -

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>

and following index.fcgi file:

#!/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()

The Django app runs successfully but inserts 'index.fcgi' in the URL like this-

www.example.com/index.fcgi/admin instead of www.example.com/admin

How can I strip the script name from the URL ?

I tried following the instructions here - http://flask.pocoo.org/docs/0.10/deploying/fastcgi/

But it is for flask and I can't get it running for Django.

P.S - I am on a shared hosting plan with no root access of the server.

Shivendra
  • 556
  • 3
  • 15

1 Answers1

1

I just added this in my .htaccess file. It was enough for hidding index.fcgi from URLs.

<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>
Tim
  • 11
  • 1