Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
820 views
in Q2A Core by

I have applied these NGINX settings to make it work for .htaccess rewrite rule

location / {

try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;

}

location /index {

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

root html;

try_files $uri =404;

fastcgi_read_timeout 300;

fastcgi_pass   unix:/opt/bitnami/php/var/run/www.sock;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME $request_filename;

includefastcgi_params;

}

I have also applied setting to work for custom 404 page by q2a

here is code, just add in config file:

error_page 404 /404.html;

location = /404.html {

try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;

}

Everything is working well on NGINX server but the two error I got while testing the site. HERE are the result:

APACHE server NGINX server
  1. If you access any question url with .php extension Ex. - https://www.question2answer.org/qa/80474/htaccess-working-nginx-server-please-make-work-support-site.php

You will be redirected to the original url without file extension i.e https://www.question2answer.org/qa/80474/htaccess-working-nginx-server-please-make-work-support-site 

  1. But If you access any question url with .php extension Ex. - https://www.question2answer.org/qa/80474/htaccess-working-nginx-server-please-make-work-support-site.php

It is giving 404 error.

2. If you access this url with .php extension I'm getting 404 error.
https://www.question2answer.org/qa/user/j.kargo/activity.php
2. If you access this url with .php extension I'm getting 404 error for static files but url loads.
https://www.question2answer.org/qa/user/j.kargo/activity.php

 This is my complete configuration:

location / {

try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;

}

location /index {

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

root html;

try_files $uri =404;

fastcgi_read_timeout 300;

fastcgi_pass   unix:/opt/bitnami/php/var/run/www.sock;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME $request_filename;

includefastcgi_params;

}

error_page 404 /404.html;

location = /404.html {

try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;

}

I expect help from anybody regarding this.

Thanks in advance 

Q2A version: 1.8.3

1 Answer

0 votes
by
...