在apache安装程序中,我掩盖了WordPress后面的WordPress /admin
。
我用下面的规则完成了这个工作:
RewriteRule admin/(.*).php wordpress/wp-admin/$1.php [L] RewriteRule /admin$ admin/ [L,R=301] RewriteRule ^admin/$ wordpress/wp-admin/index.php [L]
所以nginx的最后一条规则很简单:
rewrite ^/admin/$ /wordpress/wp-admin/index.php last;
或多或less的一个单词重复。
第二条规则似乎并不是必要的……它只是在那里最后强行斜线。
第一条规则似乎没有回升。 我有nginx的输出debugging信息的重写,它似乎没有写任何东西像urls /admin/edit.php
这里是我的整个nginxconfiguration,如果在那里会有一些信息块:
worker_processes 1; events { worker_connections 1024; } error_log /var/log/file.log notice; http { rewrite_log on; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /home/meul/site/htdocs/web; index index.php index.html index.htm; if (-f $request_filename) { expires max; break; } rewrite ^/admin/(.*).php$ /wordpress/wp-admin/$1.php break; rewrite ^/admin/$ /wordpress/wp-admin/index.php last; if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") { rewrite ^(.*) /index.php last; } } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/www/nginx-dist; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/meul/site/htdocs/web$fastcgi_script_name; include fastcgi_params; } }
更改
rewrite ^/admin/(.*).php$ /wordpress/wp-admin/$1.php break;
至
rewrite ^/admin/(.*)\.php$ /wordpress/wp-admin/$1.php last;
break
停止处理当前的位置块,但在这种情况下,你仍然需要location ~ \.php$
块服务pipe理员的PHP。 此外,因为这是一个正则expression式,你想逃避文字。 之前的PHP扩展。