Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

web.config redirect all requests

Is it possible to redirect all my web requests to index.htm ? From looking at forums, Ive managed to get together:-
<?xml version="1.0"?>

<configuration>
    <system.web>
        <rule name="rule 1g" stopProcessing="true">
	        <match url="."  />
	        <action type="Rewrite" url="/index.php"  />
        </rule>
    </system.web>
</configuration>

Open in new window


However all I get is:-
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Im hoping that once the page has been redirected I can query the requested page,
Avatar of becraig
becraig
Flag of United States of America image

This should work:
    <configuration>
       <system.webServer>
          <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
             <add wildcard="*" destination="/index.php" />
          </httpRedirect>
       </system.webServer>
    </configuration>

Open in new window


I am assuming of course that you are asking to redirect all requests to index.php ?
Avatar of tonelm54
tonelm54

ASKER

When I try your example I dont get the same error but instead get:-
This webpage has a redirect loop
Oops my bad I forgot to specifiy a resource type (*.htm)

    <configuration>
       <system.webServer>
          <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
             <add wildcard="*.htm" destination="/index.php" />
          </httpRedirect>
       </system.webServer>
    </configuration>
I was hoping to do all pages, so using your example something like this:-
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
            <add wildcard="index.php" StopProcessing="true" />
            <add wildcard="*.jpg" StopProcessing="true" />
            <add wildcard="*.png" StopProcessing="true" />
            <add wildcard="*.js" StopProcessing="true" />
            <add wildcard="*" destination="/index.php" />
        </httpRedirect>
    </system.webServer>
</configuration>

Open in new window


Sorry to keep hasseling you, Im just finding resources very slim, and help files not helpful on web.config files
Hi

The following should redirect all pages , without having to specify all of them
Which version of iis are you using  ?
and you may also find this Microsoft Web Page  show how to do this through the GUI  

<configuration>
 <location>
    <system.webServer>
      <httpRedirect enabled="true" destination="http://www.newWebSite.com/" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>

Open in new window

The problem I have found with this redirect is that it redirects everything to index.php, including index.php and any js or css files I have
ASKER CERTIFIED SOLUTION
Avatar of becraig
becraig
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial