【问题标题】:How to call php api without .php extenstion in url如何在url中调用没有.php扩展名的php api
【发布时间】:2019-11-18 06:12:23
【问题描述】:

当我调用这个 api 时,你好,

https://restapiaseem.000webhostapp.com/api/employees/get.php?id=10036

我收到以下来自我的服务器的响应,

{
"id": "10036",
"name": "Karun Nair",
"designation": "Marketing Head",
"mobile": "6988889799",
"email": "karunnair@gmail.com"
}

有没有办法调用这个api看起来像这样(删除.php扩展名) https://restapiaseem.000webhostapp.com/api/employees/get?id=10036

【问题讨论】:

    标签: php android api


    【解决方案1】:

    您需要配置您的 Web 服务器(Apache Nginx、IIS)以重写 URL 或重新路由它们。

    【讨论】:

    • 我是新手,你能解释一下吗?
    • 解决方案在服务器部分//配置上。你用哪个服务器?
    • apache .htaccess 000webhost 是我的主机
    • 通过在我的 .htaccess fileRewriteEngine on RewriteCond %{REQUEST_FILENAME} 上写这些东西来解决!-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC, L]
    • 你应该看看 apache 的文档:httpd.apache.org/docs/2.4/rewrite/remapping.html 或者这个有趣的线程在 SO stackoverflow.com/questions/43967770/…
    猜你喜欢
    • 2014-09-23
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多