Question

We have a website made by Django. And there is no problem when access following url on local working environment:

http://site/tags/c%23/

"c%23" is urlencode of "c#", that works fine locally. But after we deploy it on Bluehost hosting server (apache+fastcgi), this URL has been resolved to a new address like this:

http://site/t/tags/c/ 

That's too weird. Probably it's not a Django's problem, but have something to do with Apache url's rewrite. If you have any idea or suggestion how to fix this please let me know. Thanks in advance.

Here is the .htaccess file may be considered:

AddHandler fcgid-script .fcgi 
#AddHandler fastcgi-script .fcgi 
#AddHandler application/cgi .fcgi 
#AddHandler cgi-script .fcgi 
RewriteEngine On 
RewriteBase / 
#static file setting 
RewriteRule ^(media/.*)$ - [L] 
RewriteRule ^(static/.*)$ - [L] 
RewriteCond %{REQUEST_URI} !(dispatch.fcgi) 
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L] 

and the dispatch.fcgi file:

#!/home/***/python/bin/python 
import sys, os 
# Add a custom Python path. 
sys.path.insert(0, "/home/***/python") 
sys.path.insert(0, "/home/***/working/Django-1.0") 
os.chdir("/home/***/working/Django-1.0/project") 
os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings" 
from django.core.servers.fastcgi import runfastcgi 
runfastcgi(["method=threaded", "daemonize=false"]) 

UPDAET: If this is caused by settings in httpd.conf, how can I override in .htaccess file while I don't have permission to it?

Was it helpful?

Solution

Just some tips before going further:

Have you tried with other characters such as a space (%20) or an accented ASCII character? Also, have you tried putting other characters after the %23 (other than the slash) to see if they're stripped also?

One guess could be that as the # is considered as an anchor on the current page, the # and whatever is after will be stripped in the rewrite.

OTHER TIPS

I'd have to agree with the first answer - and without access to the apache configuration, you might be out of luck. Using 'CSharp' or something in that vein might be the way to go.

# has special meaning in URI, same as / or ? does. Do you have this issue with other symbols? Ultimately, you shouldn't be using a # sign in a URI anyway, unless you're referring to an anchor on the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top