API and “normal” URLs in one Yii2 application

I would like to have (use) in my Yii2 application:

    • a standard, SEO-like URLs, with .html at the end (thus 'suffix' => '.html') and
    • API request (basing on example code from guide) without this suffix.

So, to make my application being able to serve both http://127.0.0.1/app/site/index.html-like URLs and http://127.0.0.1/uslabs/web/user/2-like API calls.

It this possible? If so, how should I configure urlManager component for this?

I went through “Quick Start” chapter in “RESTful Web Service” section, but it bring no help. They don’t use suffixes in examples given there. I’m stuck with the choice of either one or other scheme.

It might be possible, but I’m afraid that it would be complicated and tricky.

I think you should consider splitting the app in two.

At the end of the "Quick Start":

I was also strongly thinking about separating API as a separate application / application layer.

However, to conclude this thread, I’d like to point out, that there an answer to the same question asked by me on Stack Overflow, which suggests, that you can use suffix also directly inside rules and set it to NULL for all rules, that handles API-like calls.

I haven’t tested this solution so far (because I’m thinking about separating API to separate application layer), so I just want to mention it here.