doubomudichen0832
2013-10-05 20:37
浏览 76
已采纳

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.

图片转代码服务由CSDN问答提供 功能建议

我想添加Apache .htaccess规则。 这是来自旧服务器的nginx:

  location~ \ .php $ {
 fastcgi_split_path_info ^(。+ \。php)(/。+)$; 
 fastcgi_pass unix  :/var/run/php5-fpm.sock; 
 fastcgi_index index.php; 
包括fastcgi_params; 
} 
 
位置/ {
 if(-f $ request_filename){
 break; 
  } 
 if(-d $ request_filename){
 break; 
} 
 rewrite ^ /(.*)/index.php?demand=$1;
}
  \  n 
 

如何重写这个? 我现在得到的只是索引页面,找不到其余的文件。 我真的希望在这里得到一些帮助,谢谢。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • duanli0119 2013-10-06 00:24
    最佳回答

    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]
    
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题