How to replace 'dash' with 'underscore' in an IIRF rule?
Posted
by jessegavin
on Stack Overflow
See other posts from Stack Overflow
or by jessegavin
Published on 2010-06-11T18:51:12Z
Indexed on
2010/06/11
19:12 UTC
Read the original article
Hit count: 299
url-rewriting
|iirf
I have a web app which serves images based on the subdomain.
We wanted to provide our users with a url like this:
http://{username}.domain.com/images/myimage.jpg
Instead of what we used to have:
http://www.reallylongdomainname.com/users/{username}/images/myimage.jpg
This makes the url shorter and less 'snoopable'.
So I set up an IIRF .ini file to do some url rewriting and it works great except for the fact that some of our users folders have an underscore. And from what I've read, underscore is not a valid character in a domain name (even though IIS supports it).
I want to know how I could do a find and replace in the $1
back reference so that a url like this:
http://some-user.domain.com/...
Could be rewritten to this:
/users/some_user/..
Here's my IIRF rule.
RewriteCond %{HTTP_HOST} ^(?!www)([^\.]+)\.domain\.com
RewriteRule ^/(.*)$ /users/*1/$1 [L,I]
Thanks for any help.
© Stack Overflow or respective owner