搜尋

首頁  >  問答  >  主體

url-rewrite - 請教這段rewrite如何修改成nginx能夠讀懂的程式碼

這是一段.htaccess,我想修改成nginx重寫規則,我自己對網域重寫不了解,希望有朋友能夠指點一下,謝謝

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*)  [L]
RewriteRule ^(.*\.php)$  [L]
RewriteRule . index.php [L]
给我你的怀抱给我你的怀抱2752 天前894

全部回覆(1)我來回復

  • 怪我咯

    怪我咯2017-05-16 17:30:16

    找到答案了

    #ignored: “-” thing used or unknown variable in regex/rew
    rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /wp-admin/ permanent;
    if (-f $request_filename){
        set $rule_2 1;
    }
    if (-d $request_filename){
        set $rule_2 1;
    }
    if ($rule_2 = "1"){
    #ignored: “-” thing used or unknown variable in regex/rew
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) / last;
    rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ / last;
    rewrite /. /index.php last;
    

    回覆
    0
  • 取消回覆