关于IIS上Yii2的Url路由美化

Yii2默认的路由是酱紫的

http://.../admin/web/index.php?r=site/login

心中理想的美化Url应该这样  http://.../admin/web/site/login

在指定模块的web目录新建web.config,复制粘贴下面代码就OK了!

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
        <rewrite>
			<rules>
				<rule name="OrgPage" stopProcessing="true">
					<match url="^(.*)$" />
					<conditions logicalGrouping="MatchAll">
						<add input="{HTTP_HOST}" pattern="^(.*)$" />
						<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
						<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
					</conditions>
					<action type="Rewrite" url="index.php/{R:1}" />
				</rule>
			</rules>
		</rewrite>
    </system.webServer>
</configuration>

可能会遇到其他问题,欢迎留言

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

posted @ 2017-07-09 23:29  程序生(Codey)  阅读(1143)  评论(1编辑  收藏  举报