-1

I am trying to understand how to get this location block to work as desired.

## TESTING MOD REWITE FROM APACHE...
location /beta9/projects/project/ {
    try_files $uri $uri/ /beta9/projects/project/index.php?$args;
    fastcgi_pass   php_processes;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    include        fastcgi_params;

}

How can I take the following URL

MASKED URL

http://localhost/beta9/projects/project/574

..and process it as...

RAW URL

http://localhost/beta9/projects/project/?project_id=574

As you can see, these url parameters do not get passed and the php page breaks.

suchislife
  • 356
  • 4
  • 11

1 Answers1

0

Alright. First of all thank you for the downvote as it inspired even more research on my part. Once you grow tired of searching for this answer on stackoverflow and serverfault, remember to bookmark the one with 1 or more downvotes and no feedback what-so-ever. It is ironically the one.

The following single line of code worked as a solution.

## REWRITE - SEGMENT TO PARAMETER Coversion
location ~ /beta9/projects/project/ {
    rewrite ^/beta9/projects/project/(\d+)$ /beta9/projects/project/index.php?project_id=$1 last;
}

It would be really nice to at least get some feedback on if there's any redundancy in this solution and if there's a more elegant way of doing it.

suchislife
  • 356
  • 4
  • 11