Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Howto run configure it right on Nginx Web Server ?

+3 votes
asked Oct 31, 2010 in Q2A Core by anonymous
Same as subject.

4 Answers

+1 vote
answered Nov 1, 2010 by gidgreen
If you can get nginx up and running with PHP and MySQL, it shouldn't be an issue.

Try this Google search for starters: http://www.google.com/search?q=nginx+php+mysql
+3 votes
answered Oct 27, 2011 by BubkaGob
edited Jun 11, 2016 by Scott

it works for default URLs like


For SEO optimized urls like this /123/why-do-birds-sing you need to set rewrite rule in nginx config

if (!-e $fastcgi_script_name) {
    rewrite ^/(.+)?$ /index.php?qa-rewrite=$1 last;

or if your question2answer root directory is q2a

rewrite ^/q2a/(.+)?$ /q2a/index.php?qa-rewrite=$1 last;

it works fine for me

commented Dec 12, 2011 by Sergey Ivanov
try_files $uri $uri/ /index.php?qa-rewrite=$uri&$args;
commented Sep 3, 2013 by susuario
This answer went perfect in my server.

–1 vote
answered Apr 8, 2013 by Ashish Sharma
edited Jun 11, 2016 by Scott

For SEO optimized url & if root directory is different, below is the correct script

if (!-e $fastcgi_script_name) {
    rewrite ^/q2a/([a-z\/]+)(\?.+)?$ /q2a/index.php?qa-rewrite=$1&$args last;
commented Oct 13, 2013 by ac
This would not work at present where the q&a take the URL form /q2a/12/some-question as the number after q2a is not captured by your regex.

Also categories with symbols in URL will not work with this regex. For example Computers & IT category will become computers-%26-it in SEO friendly URL which will return a 404 for this regex you have given.

The regex in the answer above you by BubkaBob will work fine and is correct.
+2 votes
answered Jan 6 by rrrhys

The other answers lead to 404's on all images etc for me. The one that worked for me was:


location / {
    index index.php index.html index.htm;
    if (!-e $request_filename) {
       rewrite ^/(.+)?$ /index.php?qa-rewrite=$1 last;