Web.config将所有路径重定向到index.php – 无法正常工作

Web.config将所有路径重定向到index.php – 无法正常工作,第1张

概述我主要使用Apache和.htaccess,但我目前正在一个托管在 Windows服务器上的网站上工作. Web.config给我带来了很多问题. 我正在尝试将所有URL请求重定向到index.php,以便PHP脚本可以解析URL并提供正确的页面. .htaccess(在Apache上运行正常)如下: RewriteEngine OnRewriteCond %{REQUEST_FILENAME} 我主要使用Apache和.htaccess,但我目前正在一个托管在 Windows服务器上的网站上工作. Web.config给我带来了很多问题.

我正在尝试将所有URL请求重定向到index.PHP,以便PHP脚本可以解析URL并提供正确的页面.

.htaccess(在Apache上运行正常)如下:

RewriteEngine OnRewriteCond %{REQUEST_filename} -s [OR]RewriteCond %{REQUEST_filename} -l [OR]RewriteCond %{REQUEST_filename} -dRewriteRule ^(.*)$- [NC,L]RewriteRule ^(.*)$/index.PHP [NC,L]

Web.config重写(不想工作):

<rewrite>        <rules>            <rule name="rule 1G" stopProcessing="false">                <match url="^(.*)$"  ignoreCase="true" />                <action type="Rewrite" url="/-"  />            </rule>            <rule name="rule 2G" stopProcessing="false">                <match url="^(.*)$"  ignoreCase="true" />                <action type="Rewrite" url="//index.PHP"  />            </rule>        </rules>    </rewrite>

这是我的Apache测试服务器上的站点:http://villasilvana.hotmintmedia.com
在这里的实时windows服务器上:http://www.villasilvana.net(更新 – 我必须将实时网站恢复为原始网站,因为它仍在使用中)

我在ISS和Web.config上浏览了无数页面,并尝试了重写代码的许多变体,但没有一个有效.我将不胜感激任何帮助.

解决方法 我知道现在有点晚了,但万一其他人在看

<!--web.config url rewrite--><configuration>   <system.webServer>      <rewrite>          <rules>              <rule name="Redirect To Index" stopProcessing="true">                  <match url=".*" />                  <conditions>                      <add input="{REQUEST_filename}" matchType="Isfile" negate="true" />                      <add input="{REQUEST_filename}" matchType="IsDirectory" negate="true" />                  </conditions>                  <action type="Rewrite" url="/index.PHP" />              </rule>          </rules>      </rewrite>  </system.webServer></configuration>
总结

以上是内存溢出为你收集整理的Web.config将所有路径重定向到index.php – 无法正常工作全部内容,希望文章能够帮你解决Web.config将所有路径重定向到index.php – 无法正常工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1043336.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存