Dual Re-Writing

Mar 4, 2010 at 5:57 PM

I am using this to rewrite based on the following rules...

#------- Main Processing ---------#
# ASP #
RewriteRule ^/page/([^\?\/]+)$ /default.asp?page=$1  [L]


How can I do this to do the same rewrite but for default.php, without causing an issue

# PHP #
RewriteRule ^/page/([^\?\/]+)$ /default.php?page=$1  [L]

Mar 4, 2010 at 6:57 PM

You can't do both.  You can only rewrite to one or the other.

If you get a request like /page/foo ,  how exactly do you want to rewrite it?  To an ASP page?  or a PHP page?  you cannot rewrite it to both.  You have to choose one.

It may be that you want to rewrite it to the ASP page, if it exists, and if not then rewrite it to the PHP page, if it exists.  But I don't know how you would figure that out, within the scope of the IIRF rewriting.  If there is a filesystem file or directory for each extant page that can be referenced by default.asp or default.php, then you could  use the RewriteCond with the -f or -d flags to test for this.  Check the documentation on Special Patterns for RewriteCond for more information on that.

Another way to accomplish what you want is to use a separate URL namespace for asp pages and php pages.  in other words, a URL path of /asppage/foo would be rewritten to /default.asp?page=foo , while a URL path of /phppage/foo would be rewritten to /default.php?page=foo .


Mar 4, 2010 at 8:08 PM

2 seperate sites, but on the same server.


One site is ASP, the other is PHP.


I am unsure what version of the component that I have, but I think it's older than v2

Mar 4, 2010 at 8:55 PM

oh, ok.

Then, do this:

  1. Upgrade to IIRF v2.0 or v2.1.
  2. create an IIRF.ini with the rule for ASP, put it in the directory for the ASP site. 
  3. create another IIRF.ini with the rule for PHP , put it in the directory for the PHP site.


Mar 4, 2010 at 8:58 PM

do they go right in the websites root folder?


I really appreciate this man!

Mar 5, 2010 at 4:09 AM

More or less. 

They go in the document root of the IIS application.  For a website, that's the website root folder.  But it's not always the website root folder.


Mar 6, 2010 at 2:58 PM

Thank you very much man, works a charm.