2014-08-28 25 views
0

我在Nginx中使用了一個非常特殊的配置來重寫URL,但是它會阻塞/ phpmyadmin。PHPMyAdmin和Nginx

我已經嘗試噸不同的方式製造PMA回來,但沒有任何工作..

請幫我做PMA可與此配置中的URL重寫WP:

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; 
} 

回答

0

第二到上一次重寫規則將採取任何字符串,包括至少一個字符和「php」並重定向它。這是因爲第二個.未被轉義,所以它是通配符,而不是字面點。嘗試

rewrite ^/(.*\.php)$ /$1 last; 

看看是否有幫助。

關於更一般的方法:爲什麼不在你的nginx配置中創建第二個服務器塊,並在其上指向一個子域,例如, db.mysite.com?額外的好處是,如果您在本地定義子域(例如在/etc/hosts)而不是在公共DNS中,那麼沒有該子域定義的任何人都不會看到您的phpmyadmin安裝。您可以解決所有這些嘗試在公共服務器所在的虛擬主機上運行phpmyadmin的難題。

+0

嘗試,但沒有改變..對於DNS,問題是,我在我的DNS設置wilcard * .domain.tld WP上的多站點.. – user3720154 2014-08-28 14:30:49

+0

這是特別是這導致問題:重寫/。 /index.php最後;當我註釋掉其他重寫指令(如你給我的指令)不會改變任何東西。當我評論前面提到的那個時,PMA可以,但是我在MP上的URL重寫失敗.. – user3720154 2014-08-28 14:34:32