• IIS下 Yii Url重写


    1. 下载URL重写组件 http://www.microsoft.com/zh-cn/download/details.aspx?id=7435
    2. 导入官方提供的.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如下

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <directoryBrowse enabled="false" />
            <rewrite>
                <rules>
                    <rule name="已导入的规则 1">
                        <match url="." ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <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>

       5. 修改config.php

    'urlManager' => array(
                'urlFormat' => 'path', //URL 格式。共支持两种格式: 'path' 格式( 如:/path/to/EntryScript.php/name1/value1/name2/value2... ) 和'get' 格式( 如:/path/to/EntryScript.php?name1=value1&name2=value2...)。当使用'path'格式时,需要设置如下的规则:
                'showScriptName'=>false,
    //            'urlSuffix'=>'.html',
                'rules' => array(//URL 规则。语法:<参数名:正则表达式>
                    '<controller:w+>/<id:d+>' => '<controller>/view',
                    '<controller:w+>/<action:w+>/<id:d+>' => '<controller>/<action>',
                    '<controller:w+>/<action:w+>' => '<controller>/<action>',
                ),
            ),

    本文来自博客园,作者:Bin_x,转载请注明原文链接:https://www.cnblogs.com/Bin-x/p/4048700.html

  • 相关阅读:
    Android中Services之异步IntentService(二)
    Android服务之Service(其一)
    JPA 2.0 中的动态类型安全查询
    JPA注解参考
    WebService netbeans glassfish
    android ContentProvider
    github
    移动端
    php
    mysql
  • 原文地址:https://www.cnblogs.com/Bin-x/p/4048700.html
Copyright © 2020-2023  润新知