WebFaction
Community site: login faq

I have a Django app running and, along with it, I'm running a static only app on a sub path of the site (e.g. mysite.com/some-cool-path/) and I would like this sub path to be case insensitive and, ideally, take accept a number of patterns and canonically redirect to the path that I set for the static app. I tried adding a rewrite rule to the Django app's httpd.conf and it didn't seem to take. Does anyone know how I can accomplish this?

asked 01 Dec '11, 14:18

chrisforrette
122
accept rate: 0%

Using rewrites in httpd.conf is the correct approach.

What rewrite rule did you use?

Did you restart Apache after modifying httpd.conf?

When you say "it didn't seem to take", exactly what did you see?

(01 Dec '11, 16:06) seanf

Yes, I restarted after tweaking the httpd.conf. I added the following right after all of the 'LoadModule' lines:

RewriteEngine On
RewriteRule ^shapesandsmiles/?$ shapesandsmiles/ [R=301,NC,L]

... basically just attempting to make it case-insensitive (NC), but when I visit the path and enter any capital letters, I get a 404 from the Django application.

(01 Dec '11, 17:01) chrisforrette

You need to put rewrites that are in httpd.conf within location tags.

(01 Dec '11, 18:00) johns

Thanks johns! I got this to work but the case-insensitive (NC) directive doesn't seem to be working, any idea why that might be? I wrapped the code I posted above in: <location>

(02 Dec '11, 13:55) chrisforrette

The rewrite rules you should use are:

RewriteEngine on
RewriteRule ^/shapesandsmiles/(.*)$ /shapesandsmiles/$1 [R=301,NC,L]

Note that the rewrite rules do not need to be inside of a Location directive in your httpd.conf.

Hope that helps!

permanent link

answered 02 Dec '11, 16:55

seanf
12.2k41836
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×225
×125
×76

question asked: 01 Dec '11, 14:18

question was seen: 4,107 times

last updated: 02 Dec '11, 16:55

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM