我使用yii2高级模板开发了一个应用程序。我使用了mohit's answer to hide fronted/web,它在我的localhost中成功运行。在我们的办公室,我们有一个Windows服务器。我知道我必须将.htaccess
文件转换为web.config
才能在Windows服务器中运行。我用了这个online .htaccess to web.config converter。
但是服务器有这个回复。
500 - 内部服务器错误。您的资源存在问题 正在寻找,它无法显示。
这是@mohit给出的.htaccess。
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
这是转换后的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>
哪里有错误?请帮助我