Home >Backend Development >PHP Tutorial >PHPFastCGI 404 solution under Nginx alias
It is described as follows in Nginx’s official wiki
The alias directive cannot be used inside a regex-specified location. If you need to do this you must use a combination of rewrite and root.
In actual use, the php under alias returns 404, but the html can indeed be displayed normally, solved The method is as follows
location / {
root /opt/www/htdocs/www;
index index.php index.html index.htm;
}
location /bbs/ {
alias /opt/www/htdocs/bbs/;
index index.php index.html index.htm;
}
location ~ ^/bbs/.+.php{
root /opt/www/htdocs;
rewrite /bbs/(.*.php?) /1 break;
include conf/fcgi.conf;
fastcgi_pass 127.0.0.1:10080;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/www/htdocs/bbs$fastcgi_script_name;
}
Replace alias with root and rewrite
Source: http://blog.tcisv.cn/index.php/2009/06/phpfastcgi%E5%9C%A8nginx%E7%9A%84alias%E4%B8% 8B404%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above introduces the 404 solution of PHPFastCGI under Nginx alias, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.