[英]Clean URL Re-Writing for PHP at IIS Server
我是一名php开发人员,我需要你的帮助。 我有一个网站,我希望我所有清理过的URL都来自我的index.php文件我已经在.htaccess中完成了这个,但是这个文件现在在IIS服务器上工作:(
如果用户点击“xyz.com/1”或“xyz.com/2”,那么这将调用“xyz.com”下的index.php文件
问题是IIS服务器显示“/ 1”或“/ 2”不存在。
我希望在我的URL之后传递一个数字,它将调用我的index.php如果传递任何字符串,如'/ user'或'/ manager',这将查看目录。
我在监听web.config文件。 即使我已经尝试配置它,但是当我上传该文件时,这将生成内部服务器错误:)
请帮我!!
向我们展示您现在拥有的web.config。 或者看看我的web.config。 除非被调用文件是现有文件或目录,否则Mine文件将始终加载index.php。 文件和目录例外用于加载javascript / css / image错误。 它将使用$_GET['syst'];
将其余的url(如/ user或/ manager)发送到脚本$_GET['syst'];
我的web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="UrlRewrite - DefaultRule">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^/index.php" ignoreCase="true" negate="true" />
<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?syst={R:0}" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
但另外:检查IIS上是否安装了mod重写 。 否则它将无法工作
谢谢Paules,
我已经解决了这个问题,但也要感谢这一个:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.