James
James

Reputation: 21

Allow a url to avoid a mod_rewrite rule in .htaccess

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.

Upvotes: 2

Views: 428

Answers (1)

Eemeli Kantola
Eemeli Kantola

Reputation: 5557

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]

Upvotes: 4

Related Questions