IIS和Yii2漂亮的URL [英] IIS and Yii2 pretty URL

查看:146
本文介绍了IIS和Yii2漂亮的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IIS的.htaccess等效项是什么,以便在IIS上的Yii2中启用漂亮的URL.确实,我不知道如何使用web.conf允许这些URL.

What is the .htaccess equivalent for IIS to enable pretty URLs in Yii2 on IIS. Indeed, I don't know what could I do with web.conf to allow those URLs.

推荐答案

在您的web.config上尝试此操作并将其保存在根目录上

try this on your web.config and save it on the root

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

<directoryBrowse enabled="false" />

  <rewrite>
    <rules>
      <rule name="Hide Yii Index" 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" appendQueryString="true" />
      </rule> 
    </rules>
  </rewrite>
</system.webServer>
</configuration>

这篇关于IIS和Yii2漂亮的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆