0

I'm trying to improve my php application using Swoole for fetch notifications. As swoole runs in PHP's built in server, I'm trying to redirect my 'host/notification' requests to port 9501 where Swoole is running without success. My code in .htaccess follows below:

# redirect to 9501 if "messages/" is matched
RewriteCond %{SERVER_PORT} !^9501$
RewriteRule ^notification(.*[^/])/?$ https://%{HTTP_HOST}:9501

Is it correct to try to use this approach or since the built in server has nothing to do with Apache that is not possible?

Thanks in advance

1 Answers1

0

If you have Nginx in front of the Apache server you can use it to "redirect" the traffic to Swoole. The idea is to use it as proxy, not to make a redirect, as if the request to the URL is a POST request, then you will loose your POST data on redirect.

So in your Nginx file your can add an extra line like:

server {
    ...

    location /notification/ {
        proxy_pass http://127.0.0.1:9501;
    }

    ...
}

Cheers!