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

WBOY
Release: 2016-07-13 10:15:57
Original
1221 people have browsed it

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
Copy after login

自动生成的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>
Copy after login

  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 规则。语法:<参数名:正则表达式> '/' => '/view', '//' => '/', '/' => '/', ), ),
Copy after login

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.com true http://www.bkjia.com/PHPjc/899448.html TechArticle IIS下 Yii Url重写,iisyiiurl重写 Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!