Php URL路由在Windows共享主机中不起作用,在本地Apache中完全起作用
我正在使用PHP框架构建我的网站 我得到404-文件未找到错误时,试图访问像下面这样的lik 但是索引文件的路由和工作都很完美(下面的链接指向索引文件) 我使用以下URL结构。请注意,作为所有框架,都省略了.php扩展名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
https://'domain' / 'module' / 'function' / 'parameter'
我正在努力在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>