Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php URL路由在Windows共享主机中不起作用,在本地Apache中完全起作用_Php_.htaccess_Iis_Server_Web Config - Fatal编程技术网

Php URL路由在Windows共享主机中不起作用,在本地Apache中完全起作用

Php URL路由在Windows共享主机中不起作用,在本地Apache中完全起作用,php,.htaccess,iis,server,web-config,Php,.htaccess,Iis,Server,Web Config,我正在使用PHP框架构建我的网站 我得到404-文件未找到错误时,试图访问像下面这样的lik 但是索引文件的路由和工作都很完美(下面的链接指向索引文件) 我使用以下URL结构。请注意,作为所有框架,都省略了.php扩展名 https://'domain' / 'module' / 'function' / 'parameter' 我正在努力在windows主机中执行路由,我需要澄清两件事 .htaccess文件能否在IIS(Windows)共享服务器上工作?如果不是,如何将下面的.htac

我正在使用PHP框架构建我的网站

我得到404-文件未找到错误时,试图访问像下面这样的lik

但是索引文件的路由和工作都很完美(下面的链接指向索引文件)

我使用以下URL结构。请注意,作为所有框架,都省略了.php扩展名

https://'domain' / 'module' / 'function' / 'parameter'
我正在努力在windows主机中执行路由,我需要澄清两件事

  • .htaccess文件能否在IIS(Windows)共享服务器上工作?如果不是,如何将下面的.htaccess转换为web.config代码(我是web.config新手)
  • 在Windows共享主机中,我还有什么要考虑的吗? 我正在使用
    PHP 5.6在IIS上没有.htaccess。您可以使用web.config XML文件来实现这一点

    例如,我将此配置用于IIS上的虚拟服务器:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Rewrite to index.php">
                        <match url="index.php|robots.txt|images|test.php" />
                        <action type="None" />
                    </rule>
                    <rule name="Rewrite CI Index">
                        <match url=".*" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:0}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>  
    
    
    

    感谢您提供的宝贵链接,不幸的是,您仍然无法找到它。坚持
    重写规则^static index.php[QSA,L]
    part
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Rewrite to index.php">
                        <match url="index.php|robots.txt|images|test.php" />
                        <action type="None" />
                    </rule>
                    <rule name="Rewrite CI Index">
                        <match url=".*" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php/{R:0}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>