2017-03-31 3 views
1

Auf meinem nginx-server, wenn ich example.com/wp-admin oder example.com/login besuche, sehe ich immer die homepage meiner seite, aber wenn ich example.com/wp besuche -login.php alles funktioniert (und Login-Bildschirm wird angezeigt).nginx wordpress wp-admin umleiten nach hause

Gibt es eine Konfiguration in nginx, damit diese URLs (/ wp-admin oder wp-login) wieder funktionieren?

Hinweis: Andere Posts Permalinks wie example.com/hello-world funktioniert.

Meine configs Dateien sind:

1. /etc/nginx/nginx.conf

user www-data; 
worker_processes auto; 
pid /run/nginx.pid; 

events { 
    worker_connections 768; 
    # multi_accept on; 
} 

http { 

    ## 
    # Basic Settings 
    ## 

    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 
    # server_tokens off; 

    # server_names_hash_bucket_size 64; 
    # server_name_in_redirect off; 

    include /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    ## 
    # SSL Settings 
    ## 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE 
    ssl_prefer_server_ciphers on; 

    ## 
    # Logging Settings 
    ## 

    access_log /var/log/nginx/access.log; 
    error_log /var/log/nginx/error.log; 

    ## 
    # Gzip Settings 
    ## 

    gzip on; 
    gzip_disable "msie6"; 

    # gzip_vary on; 
    # gzip_proxied any; 
    # gzip_comp_level 6; 
    # gzip_buffers 16 8k; 
    # gzip_http_version 1.1; 
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 

    ## 
    # Virtual Host Configs 
    ## 

    include /etc/nginx/conf.d/*.conf; 
    include /etc/nginx/sites-enabled/*; 
} 

2. /etc/nginx/sites-available/worpdress.conf

## 
# You should look at the following URL's in order to grasp a solid understanding 
# of Nginx configuration files in order to fully unleash the power of Nginx. 
# http://wiki.nginx.org/Pitfalls 
# http://wiki.nginx.org/QuickStart 
# http://wiki.nginx.org/Configuration 
# 
# Generally, you will want to move this file somewhere, and start with a clean 
# file but keep this around for reference. Or just disable in sites-enabled. 
# 
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. 
## 

# Default server configuration 
# 
server { 
    listen 80 default_server; 
    listen [::]:80 default_server; 

    # SSL configuration 
    # 
    # listen 443 ssl default_server; 
    # listen [::]:443 ssl default_server; 
    # 
    # Note: You should disable gzip for SSL traffic. 
    # See: https://bugs.debian.org/773332 
    # 
    # Read up on ssl_ciphers to ensure a secure configuration. 
    # See: https://bugs.debian.org/765782 
    # 
    # Self signed certs generated by the ssl-cert package 
    # Don't use them in a production server! 
    # 
    # include snippets/snakeoil.conf; 

    root /var/www/example.com/html; 

    # Add index.php to the list if you are using PHP 
    index index.php index.html index.htm index.nginx-debian.html; 

    #server_name 127.0.0.1; 
     server_name example.com www.example.com; 

     location /favicon.ico { 
       log_not_found off; 
       access_log off; 
     } 

     location /robots.tx { 
       allow all; 
       log_not_found off; 
       access_log off; 
     } 

     location ~* /(?:uploads|files)/.*\.php$ { 
       deny all; 
     } 

    location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     #try_files $uri $uri/ =404; 
       try_files $uri $uri /index.php?$args; 
    } 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 

    # # With php7.0-cgi alone: 
    # fastcgi_pass 127.0.0.1:9000; 

    # # With php7.0-fpm: 
       fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
       fastcgi_intercept_errors on; 
     } 

    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    location ~ /\.ht { 
     deny all; 
    } 
} 

3. /etc/nginx/snippets/fastcgi-php.conf

# regex to split $uri to $fastcgi_script_name and $fastcgi_path 
fastcgi_split_path_info ^(.+\.php)(/.+)$; 

# Check that the PHP script exists before passing it 
try_files $fastcgi_script_name =404; 

# Bypass the fact that try_files resets $fastcgi_path_info 
# see: http://trac.nginx.org/nginx/ticket/321 
set $path_info $fastcgi_path_info; 
fastcgi_param PATH_INFO $path_info; 

fastcgi_index index.php; 
include fastcgi.conf; 

Antwort

1

Sie scheinen eine fehlende / in Ihrer try_files Aussage zu haben. Es sollte sein:

location/{ 
    try_files $uri $uri/ /index.php?$args; 
} 

Der zweite Term ($uri/) sollte die URI /wp-admin dazu führen /wp-admin/ umgeleitet werden und rufen Sie dann die Datei /wp-admin/index.php.

Weitere Informationen finden Sie unter this document.

+0

Vielen Dank! Das Problem wurde mit deinem Tipp gelöst! –

Verwandte Themen