.htaccess - 将 Apache 转换为 Nginx

标签 .htaccess yii nginx

它在/etc/nginx/sites-available/default 中会是什么样子? 我用的是nginx/1.6.0

<Directory "c:/wamp/www/ProjectName">
  RewriteEngine on 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
</Directory>

我试过:

 location /ProjectName {
    try_files $uri $uri/ /ProjectName/index.php?r=$request_uri;
     }

它似乎几乎可以工作,但如果我有带问号的网址: http://ProjectName.dk/Test/site/getPerson?Id=369 我得到错误?

问题是 nginx conf 还应该添加什么?

最佳答案

找到解决方案:

try_files $uri $uri/ /ProjectName/index.php?r=$query_string;

现在它与问号一起使用。

关于.htaccess - 将 Apache 转换为 Nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25077798/

相关文章:

php - 获取301重定向的使用统计

nginx - 我们可以使用 HAproxy 负载均衡器和 nginx 作为服务器吗?

ssl - 服务器在使用 https [nginx] 时显示 404

php - 在 yii2 中使用限制范围?

mysql - 如何在yii中使用in条件

ruby-on-rails - nginx:[警告] 0.0.0.0:80 上的服务器名称 ip_address 冲突,已忽略

html - 亚马逊 S3 和 .htaccess

apache - 防止执行父文件夹的 .htaccess

.htaccess - 为什么会忽略已弃用的 DefaultType?

php - Yii:如何为模型设置唯一的表别名