3

i'm trying to launch yii2 web site on windows server.

My .htaccess file:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

But when i'm trying to convert it to web.config file (using online convertors), i'm receiveing this:

<rule name="rule 1i">
    <match url="."  />
    <action type="Rewrite" url="index.php"  />
</rule>

Site is't work with this web.config (error 500). Please, give me right web.config file for my .htaccess

Dmitry
  • 123
  • 4
  • 14

2 Answers2

6

Try

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <configSections>
        <sectionGroup name="system.webServer">
            <sectionGroup name="rewrite">
                <section name="rewriteMaps" overrideModeDefault="Allow" />
                <section name="rules" overrideModeDefault="Allow" />
            </sectionGroup>
        </sectionGroup>
    </configSections>

    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^(.*)$" ignoreCase="false" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>

    </system.webServer>
</configuration>
Bizley
  • 17,392
  • 5
  • 49
  • 59
  • @bizley I am having some trouble with this. It is routing urls as they where physical paths, and not part of index.php?... Any Idea? – Pablo Palacios Mar 23 '18 at 14:51
0
Options +FollowSymlinks 
RewriteEngine On 

# deal with admin first 
RewriteCond %{REQUEST_URI} ^/advanced/(admin) 
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L] 
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L] 

RewriteCond %{REQUEST_URI} !^/advanced/backend/web/(assets|css)/  
RewriteCond %{REQUEST_URI} ^/advanced/(admin)  
RewriteRule ^.*$ backend/web/index.php [L] 


RewriteCond %{REQUEST_URI} ^/advanced/(assets|css|js)  
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L] 
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L] 
RewriteRule ^js/(.*)$ frontend/web/js/$1 [L] 

RewriteCond %{REQUEST_URI} !^/advanced/(frontend|backend)/web/(assets|css)/ 
RewriteCond %{REQUEST_URI} !index.php 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ frontend/web/index.php