I'm trying to make http://$SOMETHING.app.example.com/
transparently rewrite to http://www.example.com/app/$SOMETHING
.
The config below is giving me a 404 and I'm not sure why.
ServerName www.example.com
ServerAlias *.app.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} (.*).app.example.com
RewriteRule ^/(.*) /app/%1/$1
I'm missing something obvious, what is it?
Edit: let me make this a little clearer.
If I browse to http://www.example.com/app/abc
, I get a page. If I browse to http://abc.app.example.com/
I expect to see the same page, but I'm getting a 404 instead.
Edit2: The DNS record for *.app.example.com
is already in place and I can see my request in the access log, with the 404 status.
Edit3: After enabling the mod_rewrite log file, it appears that the post-rewrite path is "$DOCROOT/app/abc" which fails because it doesn't exist. This is a Python/WSGI application, I think that has something to do with my problem. For the moment it looks like we'll just use a regular redirect instead.