views:

144

answers:

1

Hi,

In addition to web access through my domain names, my ISP allows access to my website thruogh the following format: user.hostname.com, where user is my login name and hostname is my ISP. I have written rewrite rules to automatically remap user.hostname.com to www.mydomain.com, and this works well. It turns out however for me to view the stats on my site, my ISP requires me to access user.hostname.com/stats/index.html. With my rewrite rules in place, this gets changed to www.mydomain.com/stats/index.html and I cannot access the stats page.

Is there a way you can think of to allow user.hostname.com/stats to pass through unchanged while still rewriting all other user.hostname.com requests?

Thanks.

+4  A: 

Try this if using Apache 2.2+:

RewriteRule ^/stats(|/.*)$ - [last]
# After that the other rewrites...

Prior to Apache 2.2, mod_rewrite doesn't seem to support '-' (dash) in the substitution pattern. In that case, use the following rule:

RewriteRule ^/stats(|/.*)$ /stats$1 [last]
Eemeli Kantola
Thanks. Just tried your suggestion, but it gives a server misconfiguration error.Any other ideas?
James
Works for me, with Apache 2.2.11. What Apache version are you using? If you have other RewriteRules working, can you paste here some sample conf?
Eemeli Kantola
Only information published by ISP is Debian Linux 4.0 Apache. rewritecond %{http_host} ^user\.hostname\.com [nc]rewriterule ^(.*)$ http://www.mydomain.org/$1 [r=301,nc]rewritecond %{http_host} ^www\.hostname\.com [nc]rewriterule ^(.*)$ http://www.mydomain.org/$1 [r=301,nc]rewritecond %{http_host} ^mydomain\.org [nc]rewriterule ^(.*)$ http://www.mydomain.org/$1 [r=301,nc]rewritecond %{http_host} ^mydomain\.com [nc]rewriterule ^(.*)$ http://www.mydomain.org/$1 [r=301,nc]rewritecond %{http_host} ^www.mydomain\.com [nc]rewriterule ^(.*)$ http://www.mydomain.org/$1 [r=301,nc]
James
Thanks for taking another look at this. Sorry about the lack of line breaks - I can't see how to leave a comment and leave the breaks intact.
James
Through live chat with my ISP, I was able to determine that they're running Apache version 1.3.33
James
(All of the rules should have a www. in front of mydomain.org. The comment process keeps truncating it.)
James
I edited the answer to take pre-Apache 2.2 into account.
Eemeli Kantola
...but I could'n test on Apache 1.3 it because I don't have it installed right now. So, does that work with now?
Eemeli Kantola
Unfortunately, your second solution doesn't work for me either - same server misconfiguration error, even with my other rewrite rules/conds commented out. I also tested a half-dozen other variations (some with rewritecond statements) that I found to accomplish the same thing. All gave the same non-result, so I'm not sure what's going on.
James
Weird... Unfortunately I can't tell where the problem is, because the conf seems correct to me after checking the Apache 1.3 docs. You should maybe ask your ISP for help (i.e. the exact error messages that get logged by Apache).
Eemeli Kantola