Mod_rewrite root of subdomain with passenger installed


#1

I have a subdomain on my account,

wedding.shsteimer.com

and ont hat subdomain I have a django app,

/ourwedding

but i don;t want the app name to ever show up in the url. I have that accomplished via an .htaccess file placed in my public directory

[code]RewriteEngine On

RewriteCond %{REQUEST_URI} !admin
RewriteCond %{REQUEST_URI} !ourwedding
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /ourwedding/$1 [L][/code]

This works pretty well, wedding.shsteimer.com/about, stays in the url, but is served from wedding.shsteimr.com/ourwedding/about

the problem is I’d like to have the same for the root. that is, if someone puts in wedding.shsteimer.com as their url, i want it served from wedding.shsteimer.com/ourwedding.

I tried the following rewrite rule, but it doesn;t seem to have any affect.

[code]RewriteEngine On

RewriteRule ^$ /ourwedding/ [L]

RewriteCond %{REQUEST_URI} !admin
RewriteCond %{REQUEST_URI} !ourwedding
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /ourwedding/$1 [L][/code]

Any ideas?


#2

If you want the application to run out of the root directory, change your urls.py to not include “ourwedding” in the URL patterns. Right now I see:

Changing the pattern to simply r’’ (empty!) should do the job.


#3

andrewf, that’s not what I want. I understand that I could accomplish this by modifying my django urls.py file.

what I want is to do this with mod_rewrite. I have my reasons, but i don’t feel like I should need to explain them.

Is there any reason that I can’t use mod_rewrite to rewrite the root url to /ourwedding?


#4

I’m not entirely sure why this isn’t working, but I do know that the functionality of mod_rewrite under domains using Passenger is somewhat limited. Since the original and the rewritten URL are both being routed to your Django application, though, the best place to put this logic really is within the application’s URL patterns, rather than in an htaccess file.