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

Filed under:
|

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

Related posts about url-rewriting

Related posts about iirf

  • IIRF Setup on IIS 5.1

    as seen on Server Fault - Search for 'Server Fault'
    I'm trying to configure IIRF 2 on IIS 5.1 running on XP Pro, so that I can run the Zend Framework. I've managed to get the filter running on a second website that I setup using one the IIS admin scripts. When I goto iirfStatus I get this: The problem is the .ini path for the site is pointing… >>> More

  • IIRF not working with AsP.NET PostBacks?

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hi, I have the following scenario Web server A: public on the internet, IIRF (current version) installed Web server B: on the intranet, visible to A, my APS.NET web app is installed on, name is pgdbtest3 I configure IIRF so that any request targetting directory /MMS/ on server A is redirected to… >>> More

  • IIRF redirect combine rules?

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I have 3 "rules". One to make sure URLs are lowercase another to include a slash at the end of directories, and a 3rd to force access to index.html pages to be thru the directory instead. The problem w/ how I have it is, sometimes this is causing multiple 301 redirects. I'd really like each rule… >>> More

  • Using IIRF to redirect to a PDF

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm using IIRF to redirect certain URLs to specific PDF files. For instance, for the URL /newsletter/2010/02 I'd like it to redirect to /pdf/newsletters/Feb2010.pdf. I'm not too hot at regular expressions, but I created the following rule: RedirectRule ^/newsletter/2010/01 /pdf/newsletters/Newsletter012010… >>> More

  • IIRF reverse proxy problem

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hi everyone, We have a java application ( Atlassian Bamboo) running on port 8085 on Windows 2003. It is accessile as http: //bamboo:8085. I am trying to setup reverse proxy for IIS6 using IIRF so content is accessible via http: //bamboo. It seems that I set it ip correctly, and I can retrieve… >>> More