【问题标题】:Apache Mod Rewrite rules giving 404 error - trying to use to create web apiApache Mod Rewrite 规则给出 404 错误 - 试图用来创建 web api
【发布时间】:2014-07-17 13:36:22
【问题描述】:

我正在使用 apache mod rewrite 将 api 子目录中的所有 url 重定向到 index.php 处的控制器:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^/api/(.*)$ /api/index.php?request=$1 [QSA,NC,L]
</IfModule>

所有 api 调用也必须是到 https,因此是服务器端口行。但是,当我对此进行测试时,我收到了 404 页面错误...

有人对为什么会出现这种情况有任何建议吗?

-斯内哈

【问题讨论】:

    标签: mod-rewrite url-rewriting asp.net-web-api


    【解决方案1】:

    试试这个:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    Options -Multiviews
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^/api/([^/]+)/?$ /api/index.php?request=$1 [QSA,NC,L]
    </IfModule>
    

    【讨论】:

    • 谢谢,很高兴它有帮助。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    • 2019-09-13
    • 2011-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多