EventSubscriber returning correct content but status code is 404 As the title says, content is being returned correctly but the status code is 404.
I have checked the .htaccess file and the Apache config file as well. All seems to be fine.
I have the following in my module routing file:
my_module.news_list:
  path: /api/{state}/news
  defaults:
    _controller: Drupal\my_module\Controller\NewsController::index
  methods: [GET]
  requirements:
    _access: 'TRUE'

This is the function that does the redirect in my EventSubscriber
public function redirectRequestToModule(GetResponseEvent $event) {
            $request = $event-&gt;getRequest();
            $validPathBegins = ['/men', '/nat'];
            // This is necessary because this also gets called on
            // node sub-tabs such as &quot;edit&quot;, &quot;revisions&quot;, etc.  This
            // prevents those pages from being redirected.
            $requestUri = $request-&gt;getRequestUri();
            if (!in_array(substr($requestUri, 0, 4), $validPathBegins)) {
                return;
            }
            
            $node = $request-&gt;attributes-&gt;get('node');
            
            // get the configured request query parameters for this content type
            
            $redirect_url = '/api' . $requestUri;
            $kernel = $event-&gt;getKernel();
            $response = $kernel-&gt;handle(Request::create($redirect_url));
            $event-&gt;setResponse($response);
        }

This is what I type in the browser: mysite.com/nat/news/
The content returned is correct but the status code is 404.
P.S There isn't a reachable path on my Drupal website like /nat/news. The path mentioned is supposed to return a list of news articles.
Creating an alias in /admin/config/search/path/add worked. I created an alias /api/nat/news/ to /nat/news
Thanks 4k4 for a much easier solution drupal.stackexchange.com/a/187497/47547