首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx重写多规则

问Nginx重写多规则
EN

Stack Overflow用户
提问于 2020-03-07 08:38:49
回答 1查看 49关注 0票数 0

我正在试着把我的服务器移到Nginx上。但是,当我将htaccess代码传输到conf文件时,我得到404错误。如何让Nginx重写下面的代码兼容?

代码语言:javascript
复制
RewriteEngine on

RewriteRule ^firmaekle\.html$ /firmaekle.php [L,QSA,R=301]
RewriteRule ^/d/([^/]*).([^/]*)\.html$ /index.php?site=$1&site2=$2 [L,QSA,R=301]
RewriteRule ^u/([^/]*)([^/]*)\.html$ /uzgun.php?site=$1&site2=$2 [L,QSA,R=301]
RewriteRule ^y/([^/]*)([^/]*)\.html$ /yonlendir.php?firma=$1&uzanti=$2 [L,QSA,R=301]
RewriteRule ^ye/([^/]*)([^/]*)\.html$ /yonlendir2.php?firma=$1&uzanti=$2 [L,QSA,R=301]
EN

回答 1

Stack Overflow用户

发布于 2020-03-07 19:35:44

你可以这样做

代码语言:javascript
复制
server {
    server_name example.com;

    rewrite ^/firmaekle\.html$ /firmaekle.php permanent;

    rewrite ^//d/([^/]*).([^/]*)\.html$ /index.php?site=$1&site2=$2 permanent;

    rewrite ^/u/([^/]*)([^/]*)\.html$ /uzgun.php?site=$1&site2=$2 permanent;

    rewrite ^/y/([^/]*)([^/]*)\.html$ /yonlendir.php?firma=$1&uzanti=$2 permanent;

    rewrite ^/ye/([^/]*)([^/]*)\.html$ /yonlendir2.php?firma=$1&uzanti=$2 permanent;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60573355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档