web.config 用于 yii2(提供的 .htaccess 文件)
web.config for yii2 (.htaccess file provided)
我正在尝试在 windows 服务器上启动 yii2 网站。
我的 .htaccess 文件:
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
但是当我尝试将其转换为 web.config 文件(使用在线转换器)时,我收到了:
<rule name="rule 1i">
<match url="." />
<action type="Rewrite" url="index.php" />
</rule>
站点无法使用此 web.config(错误 500)。
请为我的 .htaccess
提供正确的 web.config 文件
尝试
<?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>
Options +FollowSymlinks
RewriteEngine On
# deal with admin first
RewriteCond %{REQUEST_URI} ^/advanced/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/ [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/ [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/ [L]
RewriteRule ^css/(.*)$ frontend/web/css/ [L]
RewriteRule ^js/(.*)$ frontend/web/js/ [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
我正在尝试在 windows 服务器上启动 yii2 网站。
我的 .htaccess 文件:
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
但是当我尝试将其转换为 web.config 文件(使用在线转换器)时,我收到了:
<rule name="rule 1i">
<match url="." />
<action type="Rewrite" url="index.php" />
</rule>
站点无法使用此 web.config(错误 500)。 请为我的 .htaccess
提供正确的 web.config 文件尝试
<?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>
Options +FollowSymlinks
RewriteEngine On
# deal with admin first
RewriteCond %{REQUEST_URI} ^/advanced/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/ [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/ [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/ [L]
RewriteRule ^css/(.*)$ frontend/web/css/ [L]
RewriteRule ^js/(.*)$ frontend/web/js/ [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