首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Nginx重写- .htacces到nginx

Nginx重写- .htacces到nginx
EN

Stack Overflow用户
提问于 2014-11-26 19:55:11
回答 2查看 102关注 0票数 0

我希望我的apache .htaccess能够使用nginx。

我有这个.htaccess文件/代码

代码语言:javascript
运行
复制
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我希望你能帮我:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-11-26 23:07:33

它将在nginx中转换成这样的东西:

代码语言:javascript
运行
复制
server {

    server www.domain.com;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~\.php$ {
        ...
    }

}
票数 1
EN

Stack Overflow用户

发布于 2014-11-26 23:16:30

如果您想将"index.php“保存在url中,我会这样做。

代码语言:javascript
运行
复制
    location / {
        try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
        try_files $uri @redirect;
        ...
    }

    location @redirect {
        return 301 $1/index.php;
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27157802

复制
相关文章

相似问题

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