【问题标题】:remove .php extension in between of a url [duplicate]删除网址之间的.php扩展名[重复]
【发布时间】:2017-11-10 20:05:00
【问题描述】:

http://localhost/mydomain/category.php/5a05ee1037631242/we-will-rock-yaa

如何从 url 之间删除 .php 扩展名。我正在为我的项目使用核心 php。谁能帮忙。

谢谢!

【问题讨论】:

  • 你在运行什么网络服务器?如果是 Nginx,你可以简单地改变它传递给 php 套接字的文件的扩展名。
  • 请提供更多信息你在做什么。

标签: php url url-rewriting


【解决方案1】:

如果您使用的是 IIS,那么您需要安装 URL Rewrite,您可以使用 wpilauncher 找到它,并在您的 webconfig 中将其放在 <system.webServer> 标记中。

`<rewrite>
  <rules>
    <rule name="hide .php extension" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="true" />
    <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      <add input="{REQUEST_FILENAME}.php" matchType="IsFile" />
    </conditions>
      <action type="Rewrite" url="{R:0}.php" />
    </rule>
  </rules>
</rewrite>`

您也可以将它与 html 和 asp 等其他扩展一起使用。

如果您使用的是 xampp,那么您需要使用 .htaccess 并编写您的重写代码(一些 google 可以帮助您找到它。我自己使用 IIS,没有配置)。

我不知道您使用的是哪一个,所以我根据我正在使用的 IIS 写了一个答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 2014-06-19
    • 2018-06-25
    相关资源
    最近更新 更多