doubomudichen0832
doubomudichen0832
2013-10-05 20:37

Smarty .htaccess重写(来自nginx)

I want to add Apache .htaccess rules. This is from old server's nginx:

    location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

    location / {
    if (-f $request_filename) {
        break;
    }
    if (-d $request_filename) {
        break;
    }
    rewrite ^/(.*) /index.php?demand=$1;
}

How to rewrite this? All I am getting now is index page and the rest of files are not found. I am really hoping to get some help here, thanks.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • duanli0119 duanli0119 8年前

    The rewrite part should simply be:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?demand=$1 [L]
    

    To force the use of https, add this before the above rules:

    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    点赞 评论 复制链接分享
  • dprnr5559 dprnr5559 8年前

    Here is converter from nginx to apache http://labs.gidix.de/nginx/

    点赞 评论 复制链接分享

相关推荐