Question

I'm using IIS 8 on Windows Server 2012 R2. I have a PHP site where I'd like to redirect any URLs to anything that's not a file (i.e. doesn't exist OR is a directory) to a different (specific) URL. Example:

http://test.domain.com/public/file123.txt doesn't exist on the server, so it would redirect to http://test.domain.com/handlestuff.php.

http://test.domain.com/public/newfolder/ would also redirect to http://test.domain.com/handlestuff.php because it's a directory (not a file).

I've noticed that IIS's Rewrite module has a "Is not a file" condition, but I have no idea how to use this (yet!). What would be the simplest way to set this up?

Était-ce utile?

La solution

You're in the right place.

  1. Select the root of your site
  2. Open up the IIS Rewrite module
  3. Give the rule a name, and fill out the settings as follows.

This will find any address that is not a file and redirect it to http://test.domain.com/handlestuff.php

IIS Redirect

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top