search
HomeBackend DevelopmentPHP TutorialYii Url rewriting under IIS, iisyiiurl rewriting_PHP tutorial

Yii Url rewriting, iisyiiurl rewriting under IIS

 

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

The automatically generated web.config is as follows

<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>

5. Modify 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>,

How to rewrite the YII framework under IIS server to change the URL

It seems that "URL_MODE"=>2 is added to the conf file in the conf directory. I don't know if this is the case

After YII rewrites the URL rules, how can the original old address become the new address when loading?

You can only manually match the old address rules and then jump to the new address.

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

My URL structure originally was /cate_detail/literature.html, but later it was changed to /cate/literature.html. Just add the above code to the init() method of Controller.php, the parent class of all controllers

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/899448.htmlTechArticleYii Url rewriting under IIS, iisyiiurl rewriting Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !...
Statement
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
Windows安装nginx1.10.1反向代理访问IIS网站的方法Windows安装nginx1.10.1反向代理访问IIS网站的方法May 23, 2023 pm 05:40 PM

首先去官网下载软件包,解压,路径最好不要有中文nginx配置的路径问题由于在windows下文件路径可以用”\”,也可以用”\\”,也可以用”/”作为路径做分隔符。但”\”最容易引发问题,所以要尽量避免使用。不要添加path,否则会引发错误,config文件路径找不到比如我解压在e盘cmd命令定位到nginx.exe所在文件夹cde:\worksoftware\nginx-1.10.1然后执行,首先保证nginx.conf文件配置没问题其实nginx最重要的和最主要的工作就是配置文件,其他没什么

iis在linux上可以用吗iis在linux上可以用吗Mar 23, 2023 am 09:24 AM

iis不可以在linux上使用,因为iis是由微软公司提供的基于运行Microsoft Windows的互联网基本服务,是在Windows操作系统平台下开发的,所以限制了它只能在Windows操作系统下运行。

进程无法访问 Windows 11 / 10 上的文件错误修复进程无法访问 Windows 11 / 10 上的文件错误修复May 12, 2023 pm 07:10 PM

众所周知,当任何文件正在使用时,任何其他进程都无法访问/更改它。在这种情况下,当一个进程试图打开一个文件时,操作系统会锁定该文件以防止它被另一个进程修改。“该进程无法访问该文件,因为它正被另一个进程使用”是许多用户在其Windows计算机上观察到的此类错误消息。已知此错误发生在不同版本的WindowsOS和WindowsServer中。通常,在用户的WindowsPC上使用Netsh命令期间会观察到此错误消息。发生此错误的另一种情况是尝试在Internet信息服务(IIS)M

php站用iis乱码而apache没事怎么解决php站用iis乱码而apache没事怎么解决Mar 23, 2023 pm 02:48 PM

​在使用 PHP 进行网站开发时,你可能会遇到字符编码问题。特别是在使用不同的 Web 服务器时,会发现 IIS 和 Apache 处理字符编码的方法不同。当你使用 IIS 时,可能会发现在使用 UTF-8 编码时出现了乱码现象;而在使用 Apache 时,一切正常,没有出现任何问题。这种情况应该怎么解决呢?

iis应用程序池怎么打开iis应用程序池怎么打开Apr 09, 2024 pm 07:48 PM

要在 IIS 中打开应用程序池:1. 打开 IIS 管理器;2. 导航到 "应用程序池" 节点;3. 右键单击目标应用程序池并选择 "管理";4. 单击 "高级设置" 选项卡;5. 应用程序池配置可在此查看和修改。

iis无法启动怎么解决iis无法启动怎么解决Dec 06, 2023 pm 05:07 PM

iis无法启动的解决办法:1、检查系统文件完整性;2、检查端口占用情况;3、启动相关服务;4、重新安装IIS;5、重置Windows系统;6、检查元数据库文件;7、检查文件权限;8、更新操作系统和应用程序;9、避免安装过多不必要的软件;10、定期备份重要数据。详细介绍:1、检查系统文件完整性,运行系统文件检查工具,检查系统文件的完整性等等。

iis无法启动解决方法iis无法启动解决方法Oct 24, 2023 pm 03:04 PM

解决方法:1、检查IIS服务是否已安装;2、检查依赖服务;3、检查端口冲突;4、检查配置文件和权限;5、重新注册IIS相关组件;6、检查日志文件。

iis的日志文件可以删除吗怎么删iis的日志文件可以删除吗怎么删Apr 09, 2024 pm 07:45 PM

是的,可以删除 IIS 日志文件。删除方法包括:通过 IIS 管理器选择网站或应用程序池,然后在“日志文件”选项卡中删除相应日志文件。使用命令提示符转到日志文件存储目录(通常为 %SystemRoot%\System32\LogFiles\W3SVC1),并使用 del 命令删除日志文件。使用第三方工具(例如 Log Parser)自动删除日志文件。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.