在需要添加伪静态的虚拟主机的server{}中引入.htaccess文件,如图所示:
include /var/www/html/168pc/bbs/.htaccess;(把这个改成你.htaccess文件的具体位置)
Apache Rewrite伪静态规则自动转换为Nginx Rewrite网页。
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
或者直接写到server里:
server {
listen 8080;
server_name www.typofree.org;
location / {
root /var/www/typofree.org;
if (-f $request_filename) {
break;
}
if ($request_uri ~ '^/(typo3(/|conf|temp)|typo3|fileadmin|uploads|t3lib|clear.gif|index.php|favicon.ico)') {
break;
}
if (!-e $request_filename) {
rewrite .* /index.php last;
return 200;
}
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fcgid/.fastcgi.www-data/socket;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/typofree.org/$fastcgi_script_name;
}
}
typo3-nginx:
if ($request_uri ~ ‘^/(typo3(/|conf|temp)|typo3|fileadmin|uploads|t3lib|clear.gif|index.php|favicon.ico)’) { break; }
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = “21”){
rewrite ^/(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ /$1.$3 last;
}
#ignored: “-” thing used or unknown variable in regex/rew
rewrite ^/typo3$ /typo3/index_re.php last;
if (!-f $request_filename){
set $rule_3 1$rule_3;
}
if (!-d $request_filename){
set $rule_3 2$rule_3;
}
if ($request_filename !~ “-l”){
set $rule_3 3$rule_3;
}
if ($rule_3 = “321”){
rewrite /.* /index.php last;
}
auth_basic “demo”;
auth_basic_user_file .htpasswd;