0

Its a simple redirect for someone navigating to link.html to get redirected to index.php/link/ while still keeping any query string intact.

Below works perfectly in an environment that uses IIS7 in the web.config file.

<rule name="Rewrite for link.html">
    <match url="link.html" />
    <action type="Rewrite" url="index.php/link/" />
</rule>
<rule name="Rewrite CI Index">
    <match url=".*" />
    <conditions>
        <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|ttf|eot" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="admin.php" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="index.php" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php/{R:0}" />
</rule>

I have another IIS platform that uses a plugin that acts like Apache's mod_rewrite

What's the RewriteCond / RewriteRule syntax to do something like the example above? All of my guesses blown up in different ways so far.

Here's the existing IIRF.ini file that does the Rewrite CI Index just fine:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

The question is how to get the Rewrite for link.html to fit in with this apache like syntax.

TIA for any help.

Mike_K
  • 9,010
  • 5
  • 20
  • 27

1 Answers1

1

Just add a redirect rule before the RewriteCond/RewriteRule block:

RedirectRule ^link.html(.*)$ /index.php/link/$1
marapet
  • 54,856
  • 12
  • 170
  • 184
  • Putting this up top worked: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} ^/link\.html RewriteRule ^.*$ /index.php/link [L] – Mike_K Sep 29 '12 at 20:46
  • I thought you wanted to redirect, not rewrite. Btw, you don't really need the `RewriteCond`s, simply put `RewriteRule ^/link\.html$ /index.php/link [L,I]` (I recommend to also add the `[I]` flag for case insensitive matching). – marapet Sep 30 '12 at 18:57