Ubuntu PHPMyAdmin和Nginx
我在Nginx中使用了一个非常特殊的配置来重写URL,但它会阻止/phpmyadmin 我尝试了很多不同的方法让pma恢复,但没有任何一种有效的方法 请帮助我使PMA使用此配置在WP中重写url:Ubuntu PHPMyAdmin和Nginx,ubuntu,nginx,phpmyadmin,rewrite,Ubuntu,Nginx,Phpmyadmin,Rewrite,我在Nginx中使用了一个非常特殊的配置来重写URL,但它会阻止/phpmyadmin 我尝试了很多不同的方法让pma恢复,但没有任何一种有效的方法 请帮助我使PMA使用此配置在WP中重写url: server { listen 80; server_name localhost; root /var/www; # Static location / { index index.html index.htm
server
{
listen 80;
server_name localhost;
root /var/www;
# Static
location / {
index index.html index.htm index.php;
}
# PHP scripts -> PHP-FPM server listening on 127.0.0.1:9000
location ~ \.php$ {
# The following line prevents malicious php code to be executed through some uploaded file (without php extension, like image)
# This fix shoudn't work though, if nginx and php are not on the same server, other options exist (like unauthorizing php execution within upload folder)
# More on this serious security concern in the "Pass Non-PHP Requests to PHP" section, there http://wiki.nginx.org/Pitfalls
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# Security
location ~ /\.ht {
deny all;
}
# Stuffs
location = /favicon.ico {
access_log off;
return 204;
}
rewrite ^/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"){
}
rewrite ^/(wp-(content|admin|includes).*) /$1 last;
rewrite ^/(.*.php)$ /$1 last;
rewrite /. /index.php last;
}
倒数第二个重写规则将获取任何字符串,包括至少一个字符和“php”,并重定向它。这是因为第二个
没有转义,所以它是一个通配符,而不是文字点。试一试
rewrite ^/(.*\.php)$ /$1 last;
看看这是否有帮助
更一般的方法是:为什么不在nginx配置中创建第二个服务器块,并将子域指向它,例如db.mysite.com?额外的好处是,如果您在本地(例如在
/etc/hosts
中)而不是在公共DNS中定义子域,则没有该子域定义的任何人将永远看不到您的phpmyadmin安装。您可以绕过所有这些麻烦,尝试在与公共服务器相同的虚拟主机上运行phpmyadmin。尝试过,但没有任何改变。。对于DNS,问题是我在DNS设置中为WP上的多个站点设置了一个wilcard*.domain.tld。这就是导致问题的原因:rewrite//index.php last;当我注释掉其他重写指令(比如你给我的那个)时,它不会改变任何东西。当我评论前面提到的那个时,PMA是可以的,但是我的url在MP上重写失败了。。