2

I have developed an application using yii2 advanced template. I used mohit's answer to hide fronted/web and it successfully works in my localhost. In our office, we have a windows server. I know that I have to convert the .htaccess file to web.config in order for it to work in the windows server. I used this online .htaccess to web.config converter.

But the server had this reply.

500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed.

Here is the .htaccess given by @mohit.

Options +FollowSymlinks
RewriteEngine On

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

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


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

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

And here is the converted web.config

<rule name="rule 1V" stopProcessing="true">
    <match url="^admin/assets/(.*)$"  />
    <action type="Rewrite" url="/backend/web/assets/{R:1}"  />
</rule>
<rule name="rule 2V" stopProcessing="true">
    <match url="^admin/css/(.*)$"  />
    <action type="Rewrite" url="/backend/web/css/{R:1}"  />
</rule>
<rule name="rule 3V" stopProcessing="true">
    <match url="^.*$"  />
    <action type="Rewrite" url="/backend/web/index.php"  />
</rule>
<rule name="rule 4V" stopProcessing="true">
    <match url="^assets/(.*)$"  />
    <action type="Rewrite" url="/frontend/web/assets/{R:1}"  />
</rule>
<rule name="rule 5V" stopProcessing="true">
    <match url="^css/(.*)$"  />
    <action type="Rewrite" url="/frontend/web/css/{R:1}"  />
</rule>

WHERE DID I GO WRONG??? PLEASE HELP ME

Community
  • 1
  • 1
beginner
  • 2,024
  • 5
  • 43
  • 76

0 Answers0