1

I have a remote apache server with php.

The folder structure is:

/html/api/v3/.htaccess
/html/api/v3/getData.php

The .htaccess contains:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^get/estimates/?$ getData.php?estimatesFilter=all [L]
RewriteRule ^get/estimates/(\d+)/?$ getData.php?estimateId=$1 [L]

The (non-physically existing) url external end points are:

/html/api/v3/get/estimates ---now points to---> getData.php?estimatesFilter=all
/html/api/v3/get/estimates/1001 ---now points to---> getData.php?estimateId=$1

I have a local nginx server running in FastCGI mode for php.

worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    # Max value 16384
    worker_connections  8192;
    # Accept multiple connections
    multi_accept on;
}

# Settings that affect all server blocks
http {
    include php_processes.conf;
    include       mime.types;
    default_type  application/octet-stream;

    access_log  logs/access.log;

    sendfile on;

    keepalive_timeout  65;
    ssl_session_timeout 10m;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3;
    ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS; 
    ssl_prefer_server_ciphers on;
    gzip  on;
    # http server

# Begin HTTP Server
server {
    listen 80; # IPv4
    server_name localhost;

    ## Parametrization using hostname of access and log filenames.
    access_log logs/localhost_access.log;
    error_log logs/localhost_error.log;

    ## Root and index files.
    root html;
    index  index.php index.html index.htm;

    ## If no favicon exists return a 204 (no content error).
    location = /favicon.ico {
        try_files $uri =204;
        log_not_found off;
        access_log off;
    }

    ## Don't log robots.txt requests.
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    ## Try the requested URI as files before handling it to PHP.
    location / {

        ## Regular PHP processing.
        location ~ \.php$ {
            try_files  $uri =404;
            fastcgi_pass   php_processes;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        ## Static files
        location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
            expires max;
            log_not_found off;
            ## No need to bleed constant updates. Send the all shebang in one
            ## fell swoop.
            tcp_nodelay off;
            ## Set the OS file cache.
            open_file_cache max=1000 inactive=120s;
            open_file_cache_valid 45s;
            open_file_cache_min_uses 2;
            open_file_cache_errors off;
        }

        ## Keep a tab on the 'big' static files.
        location ~* ^.+\.(?:ogg|pdf|pptx?)$ {
            expires 30d;
            ## No need to bleed constant updates. Send the all shebang in one
            ## fell swoop.
            tcp_nodelay off;
        }

    } # / location

} 
# End HTTP Server

}

How do I do the same in nginx? I have exhausted my patience trying to figure this out...

  • What is the correct URI for getData.php? The configuration suggests /api/v3/getData.php. Also, when you show URL end points, do you mean /html/api/v3/get/estimates or /api/v3/get/estimates? – Richard Smith Mar 3 '20 at 10:40
  • /html is the root thus a request to http://localhost/api/v3/get/estimates should point to http://localhost/api/v3/getData.php?estimatesFilter=. The same goes for http://localhost/api/v3/get/estimates/1001 should point to http://localhost/api/v3/getData.php?estimateId=. – suchislife Mar 3 '20 at 16:30
0

The default web root will be /var/www/html/

So, you need to use http://yourdomain.com/api/v3/getData.php

  • It doesn't work. – suchislife Mar 28 '20 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.