Score:1

how to set up nginx aliases on a localhost development server?

az flag

Struggling to adapt nginx to my framework and get the equivalent of, in apache config :

Alias /site1  "/home/framework/public_HTML"

(and then localhost/site1 displays site1 with local/dev settings thanks to $_SERVER['REQUEST_URI'])

What I have now with nginx :

server {

 listen localhost:80;

 server_name localhost;

 root /home/framework;
 index /public_HTML/index.php;

 location /site1 {

    # alias /home/framework/public_HTML/;
    # index index.php;
    # try_files $uri $uri/ =404; 
    # try_files /home/framework/public_HTML/index.php =404; 

 }

 location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
 }
 location ~ /\.ht {
    deny all;
 }
}

-> whether I comment in or out the lines in location /site1, all or none, adding removing trailing slash all around... => transparent redirect to localhost/site1/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/ (as copied from the url in the browser)

So, with everything commented out as it is shown, the correct index.php is getting the request & i'm getting a response but the url in the url bar and the $_SERVER['REQUEST_URI'] passed by nginx to my index.php file becomes

 /site1/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/

Why this loop ?

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.