0

I have succesfully set up Django, angularjs and phantomJS (for SEO purposes) to work together, however I am having a small problem with routes.

http:// something.com/?_escaped_fragment_= gets rewritten correctly and I get a rendered snapshop of my page (served by phantomJS), however http:// something.com/news/?_escaped_fragment_= does not and I get a 404 not found error.

Without the _escaped_fragment_ part, both sites are found and rendered correctly.

Here's my nginx config:

server {
 listen 80;
 server_name something.com;
 location = /favicon.ico { access_log off; log_not_found off; }
 location /static/ {
    root /home/folder/project;
 }
 root /home/folder/project/frontend/;
 index index.html;

 if ($args ~ _escaped_fragment_) {
    rewrite ^ /snapshot$uri;
 }

 location ~ ^/snapshot(.*) {
    rewrite ^/snapshot(.*)$ $1 break;
    # I commented out this line to test why PhantomJS wasn't rendering pages
    # such as /news correctly
    #proxy_pass http://something.com:8888;
    proxy_set_header Host $host;
    proxy_connect_timeout 60s;

 }

 location / {
     #proxy_set_header Host $http_host;
     #proxy_set_header X-Real-IP $remote_addr;
     #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     #proxy_set_header X-Forwarded-Proto $scheme;
     #proxy_pass http://unix:/home/folder/project/project.sock;
     try_files $uri $uri/ /index.html;
    }

 location /admin/ {
     proxy_set_header Host $http_host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_pass http://unix:/home/folder/project/project.sock;
 }

}

What am I missing?

EDIT: Basically, the problem is that the request URL's going through to phantomJS are in the form of http:// something.comnews (Notice the lack of /)

1 Answer 1

0

Well, looks like changing the rewrite for phantomJS to this:

rewrite ^/snapshot(.*)$ /$1 break;

did the trick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .