Forum Moderators: phranque

Message Too Old, No Replies

Django htaccess issue

         

dolcevita

2:27 pm on Apr 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have just received some customer website where i need to place some .php files under directory solutions that are accessible via website.

whatever.com/solutions/anyfile.php


But there is django installed and .htaccess make impossible to allow files from directory solution to be accessable via site.

here are rules that i have found within site:
RewriteEngine on
RewriteRule ^media/ - [L]
RewriteRule ^g2data/ - [L]
RewriteCond %{REQUEST_FILENAME} !/django.cgi.*
RewriteRule ^(.*)$ /django.cgi/$1 [L]
RewriteRule ^$ /django.cgi
#
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php



Can someone help me and post here solution that will make possible that directory solutions can be reached via website.

i.e.
http://whatever.com/solutions/anyfile.php


Right now by each request to directory that exist i receive 404 error because of .htaccess rules

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. 


Thanks

g1smd

6:48 pm on Apr 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A negative match preceding
RewriteCond
checking that
REQUEST_URI
does not begin with
^/solutions
will probably do the trick.

Be aware that a RewriteCond will apply to only the single RewriteRule that follows it.

jdMorgan

1:52 am on Apr 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That can be "compressed" a bit as well:

RewriteEngine on
#
# Rewrite all requests to /django.cgi, with the originally-requested URL-path appended as path-info,
# excluding the specified directories (Note that the second RewriteCond prevents an infinite loop)
RewriteCond $1 !^django\.cgi
RewriteCond $1 !^(media|g2data|solutions)/
RewriteRule ^(.*)$ /django.cgi/$1 [L]

I removed your last rule, because it could never be executed -- The rule before it would always match and take precedence.

Jim

dolcevita

5:30 am on May 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you Jim. I appreciate your help. Everything works smoothly.