IIS下 Yii Url重写,iisyiiurl重写_PHP教程

WBOY
Freigeben: 2016-07-13 10:15:57
Original
1273 Leute haben es durchsucht

IIS下 Yii Url重写,iisyiiurl重写

    

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
Nach dem Login kopieren

自动生成的web.config如下

<span><?</span><span>xml version="1.0" encoding="UTF-8"</span><span>?></span>
<span><</span><span>configuration</span><span>></span>
    <span><</span><span>system.webServer</span><span>></span>
        <span><</span><span>directoryBrowse </span><span>enabled</span><span>="false"</span> <span>/></span>
        <span><</span><span>rewrite</span><span>></span>
            <span><</span><span>rules</span><span>></span>
                <span><</span><span>rule </span><span>name</span><span>="已导入的规则 1"</span><span>></span>
                    <span><</span><span>match </span><span>url</span><span>="."</span><span> ignoreCase</span><span>="false"</span> <span>/></span>
                    <span><</span><span>conditions </span><span>logicalGrouping</span><span>="MatchAll"</span><span>></span>
                        <span><</span><span>add </span><span>input</span><span>="{REQUEST_FILENAME}"</span><span> matchType</span><span>="IsFile"</span><span> ignoreCase</span><span>="false"</span><span> negate</span><span>="true"</span> <span>/></span>
                        <span><</span><span>add </span><span>input</span><span>="{REQUEST_FILENAME}"</span><span> matchType</span><span>="IsDirectory"</span><span> ignoreCase</span><span>="false"</span><span> negate</span><span>="true"</span> <span>/></span>
                    <span></</span><span>conditions</span><span>></span>
                    <span><</span><span>action </span><span>type</span><span>="Rewrite"</span><span> url</span><span>="index.php"</span> <span>/></span>
                <span></</span><span>rule</span><span>></span>
            <span></</span><span>rules</span><span>></span>
        <span></</span><span>rewrite</span><span>></span>
    <span></</span><span>system.webServer</span><span>></span>
<span></</span><span>configuration</span><span>></span>
Nach dem Login kopieren

  5. 修改config.php

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

 

YII框架在IIS服务器下怎重写来改变URL

好像是在conf目录下conf文件里面添加&#39;URL_MODE&#39;=&gt;2;不知道是不是这样
 

YII 重写URL规则后,怎让原来的旧地址,载入时也变成新地址

只能手动正则匹配旧地址规则,然后跳转到新地址了.

例子:
if ( preg_match( '/cate\_detail/[^\.]+/i' ,$_SERVICE['REQUEST_URI'] ) )
{
$this->redirect($this->createUrl('category/detail', array('cate'=>'文学')), true, 301);
}

原来我的网址结构是 /cate_detail/文学.html, 后来改成/cate/文学.html 这样形式的。在所有controller的父类Controller.php的init()方法里加上上面的代码即可
 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/899448.htmlTechArticleIIS下 Yii Url重写,iisyiiurl重写 Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage