2014-10-14 2 views
1

Я установил Wordpress в подкаталог под названием/WordPressDemo. Существует домен под названием demo.example.com с корнем документа, что означает, что вам нужно ввести demo.example.com/WordPressDemo для доступа к WordPress.WordPress Multisite - Статический контент - 404 Не найдено

Я использую nGINX, что вызывает много неприятностей, мне удалось заставить основные ссылки (например, постоянные ссылки) работать, поэтому сам мультисайт работает, единственная проблема заключается в том, что он запрашивает статические данные с неправильного пути.

Пример:

Он просит:http://demo.example.com/WordPressDemo/MULTISITE-NAME/wp-includes/js/jquery/jquery.js?ver=1.11

но должен запросить

http://demo.example.com/WordPressDemo/wp-includes/js/jquery/jquery.js?ver=1.11

Мои текущие директивы Nginx:

if (!-e $request_filename) { 
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;   
      rewrite ^/WordPressDemo(/[^/]+)?(/wp-.*) /WordPressDemo$2 last;  
      rewrite ^/WordPressDemo(/[^/]+)?(/.*\.php)$ /WordPressDemo$2 last; 
    } 


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

location ~ \.php$ { 
try_files $uri /WordPressDemo/index.php; 
include  fcgi.conf; 
fastcgi_pass 127.0.0.1:9000; 
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
} 

location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { 
     access_log off; log_not_found off; expires max; 
} 
+0

Вы получаете 404 для статических файлов? – birgire

+0

Конечно, место неправильное. – Michael

+0

Серьезно? Никто не может hlp? :( – Michael

ответ

-1

Вы изучали the Wordpress codex?

Во всяком случае, вы можете быть заинтересованы в адаптации этого кода:

# WordPress multisite subdirectory rules. 
# Designed to be included in any server {} block. 

# This order might seem weird - this is attempted to match last if rules below fail. 
# http://wiki.nginx.org/HttpCoreModule 
location/{ 
     index index.php; 
     try_files $uri $uri/ /index.php?$args; 
} 

# Directives to send expires headers and turn off 404 error logging. 
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 
     expires 24h; 
     log_not_found off; 
} 

location ~ ^/[_0-9a-zA-Z-]+/files/(.*)$ { 
     try_files /sites/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ; 
     access_log off; log_not_found off; expires max; 
} 

#avoid php readfile() 
location ^~ /sites { 
     internal; 
     alias /var/www/mu/sites ; 
     access_log off; log_not_found off;  expires max; 
} 

# Uncomment one of the lines below for the appropriate caching plugin (if used). 
#include global/wordpress-ms-subdir-wp-super-cache.conf; 
#include global/wordpress-ms-subdir-w3-total-cache.conf; 

# Rewrite multisite '.../wp-.*' and '.../*.php'. 
if (!-e $request_filename) { 
    rewrite /wp-admin$ $scheme://$host$uri/ permanent; 
    rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last; 
    rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last; 
} 

# Pass all .php files onto a php-fpm/php-fcgi server. 
location ~ \.php$ { 
     # Zero-day exploit defense. 
     # http://forum.nginx.org/read.php?2,88845,page=3 
     # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi. 
     # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked. 
     try_files $uri =404; 

     fastcgi_split_path_info ^(.+\.php)(/.+)$; 


     include fastcgi_params; 
     fastcgi_pass 127.0.0.1:9000; 

     fastcgi_cache_bypass $no_cache 
     fastcgi_cache_bypass $no_cache; 
     fastcgi_no_cache $no_cache; 

     fastcgi_cache WORDPRESS; 
     fastcgi_cache_valid 6000m; 
} 

location ~ /purge(/.*) { 
     fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; 
} 

ли это ответить на ваш вопрос?

+0

Нет, копия и вставка не помогут мне. Мне действительно нужен кто-то, кто знаком с nginx и wordpress. – Michael

Смежные вопросы