H5W3
当前位置:H5W3 > 其他技术问题 > 正文

【nginx】.htaccess转nginx配置如何转

  1. apache:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
  1. nginx:
server {
listen       80;
server_name  dev.guanjia.com ;
root   "F:\phpstudy\PHPTutorial\WWW\zhifaguanjia\Web";
location / {
index  index.html index.htm index.php;
}
location ~ \.php(.*)$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_param  PATH_INFO  $fastcgi_path_info;
fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
include        fastcgi_params;
}
}

回答

试试这个

root   "F:\\phpstudy\\PHPTutorial\\WWW\\zhifaguanjia\\Web";
# 或者去掉双引号
root   F:\phpstudy\PHPTutorial\WWW\zhifaguanjia\Web;

location / {
    index  index.html index.htm index.php;
    try_files $uri $uri/ /index.php$request_uri;
}

本文地址:H5W3 » 【nginx】.htaccess转nginx配置如何转

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址