Monday, January 2, 2012

Re: Apache RewriteRule for django

Thanks for your reply, Daniel.  My reading of the documents you pointed me to was that the FastCGIExternalServer directive goes in the httpd.conf file, to which I don't have access, as I'm setting this up on a shared hosting service.  So I followed the instructions pointed to by the note further up on that page ("If you're on a shared hosting system, you'll probably be forced to use Web server-managed FastCGI processes. See the section below on running Django with Web server-managed processes for more information").  Those instructions say:

"Many shared-hosting providers don't allow you to run your own server daemons or edit the httpd.conf file. In these cases, it's still possible to run Django using Web server-spawned processes.

"If you're using Web server-spawned processes, as explained in this section, there's no need for you to start the FastCGI server on your own. Apache will spawn a number of processes, scaling as it needs to."

"In your Web root directory, add this to a file named .htaccess:

AddHandler fastcgi-script .fcgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L] 
"Then, create a small script that tells Apache how to spawn your FastCGI program. Create a file mysite.fcgi and place it in your Web directory, and be sure to make it executable: ...."

So, my .htaccess file looks just like that (with "mysite" replaced with the real name of the script). The part I don't understand is the slash between the script name and the placeholder $1. The way the filesystem syntax works, that slash tells Apache (and indirectly, the OS) that mysite.fcgi is a directory name, but it's a file, which Apache won't be able to find if it thinks mysite.fcgi is a directory in which it's supposed to find the requested resource (whatever's plugged in for the "$1" placeholder), hence the "not found" message. I'm sure there's a simple piece I'm missing here, but I just don't see it.



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/q6OLqT-ET0MJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment