Question

I've read the nginx documentation and I've read probably more than 10 post about similar issues on here, but I'm still not able to get this working right.

My basic redirects are working, but when I try to make a rewrite with some parameters, the page ends up loading funny. Just the html is loaded and all other css, images, and js files aren't loaded correctly.

I'm working on Wginx and this is the config I'm working with.

location ~ /\. {deny all;}

    location / {

        rewrite ^/index /index.php last;
        rewrite ^/arcade /arcade.php last;
        rewrite ^/info /info.php last;
        rewrite ^/info/(.*)$ /info-entry.php?pki=$1 last;


        if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
            root home/$2/public_html;
            access_log  logs/$2-access.log  main;
        }

    }

    location ~ \.php$ {

        if ($host ~ ^(www\.)?([a-z0-9\-\.]+)$){
            root home/$2/public_html;
            access_log  logs/$2-access.log  main;
        }

        if (!-e $document_root$document_uri){return 404;}
        fastcgi_pass localhost:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include fastcgi_params;

    }

The first 3 rewrites work fine (but I do think there's a simpler way to just cut the .php off instead of have a rewrite for every file)

I noticed that when I removed the following line I get some slightly different results from my info-results.php page. Not sure what's going on really.

rewrite ^/info /info.php last;
Was it helpful?

Solution

Try specifying a base tag in your <head></head>

E.g.

<base href="http://www.website.com/" target="_blank">

See <base> tag

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top