IIS and Yii2 pretty URL

那年仲夏 提交于 2019-12-07 06:13:45

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/30470618/iis-and-yii2-pretty-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!