V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
tielv
V2EX  ›  Linux

求助:PHP+apache 的伪静态规则,转换成 nginx 适用的

  •  
  •   tielv · 2014-02-27 13:29:00 +08:00 · 3722 次点击
    这是一个创建于 3708 天前的主题,其中的信息可能已经有所发展或是发生改变。
    RewriteEngine on
    RewriteCond $1 !^(index\.php|templates|upload|images|js|css|cache|plugins|spec|favicon\.ico|robots\.txt|phpmyadmin)
    RewriteRule ^(.*)$ /index.php/$1 [L]


    搞了很久了都没搞定,求助……
    6 条回复    2017-04-21 13:38:05 +08:00
    tielv
        1
    tielv  
    OP
       2014-02-27 13:29:35 +08:00
    PHP+apache的伪静态规则如下:
    RewriteEngine on
    RewriteCond $1 !^(index\.php|templates|upload|images|js|css|cache|plugins|spec|favicon\.ico|robots\.txt|phpmyadmin)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    konakona
        2
    konakona  
       2014-02-27 14:25:00 +08:00
    在我的博客搜 nginx 可以找到答案!
    www.crazyppher.com
    我现在太卡le !只能帮你到这!
    tielv
        3
    tielv  
    OP
       2014-02-27 18:54:01 +08:00
    www.crazyppher.com
    进不去呀
    tielv
        4
    tielv  
    OP
       2014-02-27 18:55:06 +08:00
    是crazyphper.com吧?
    wolftankk
        5
    wolftankk  
       2014-03-01 11:46:18 +08:00
    如果你的地址都是类似于这样 http://www.example.com/login
    这样的话可以这么写

    location .*.php {
    if (!- e $request_filename) {
    rewrite ^(.*)$ /index.php/$1 break;
    }
    }
    zhangzilong
        6
    zhangzilong  
       2017-04-21 13:38:05 +08:00
    if ($1 !~ "^(index\.php|templates|upload|images|js|css|cache|plugins|spec|favicon\.ico|robots\.txt|phpmyadmin)"){
    set $rule_0 1$rule_0;
    }
    if ($rule_0 = "1"){
    rewrite ^/(.*)$ /index.php/$1 last;
    }

    推荐一个 将 apache 重写规则在线转为 nginx 重写规则的工具:
    http://www.51ask.org/apache2nginx/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5786 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:55 · PVG 10:55 · LAX 19:55 · JFK 22:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.