我不能用htaccess在nginx中重写一条规则

时间:2015-06-05 06:53:48

标签: mod-rewrite nginx rewrite

我的htaccess中有这个规则:

RewriteRule ^(.*)\.html $1\.php

我在nginx配置中尝试使用此规则:

rewrite ^/(.*).html /$1.php;

哪里错了?有什么想法吗?

这是我在domain.net.conf中的完整配置!有什么想法吗?

server {
  server_name domain.net www.domain.net;
  access_log /home/nginx/domains/domain/log/access.log combined buffer=32k;
  error_log /home/nginx/domains/domain/log/error.log;
  root /home/nginx/domains/domain/public;
  location / {
  rewrite ^/(.*).php /$1.php;
    try_files   $uri $uri/ /index.php?$query_string;
  }
  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
}

0 个答案:

没有答案