[英]nginx load wordpress from a subdirectory
我按照這里的指南在我的ubuntu服務器上安裝了wordpress。 輸入網址后, http://mydomain.com會將我加載到首頁。
server {
listen 80 default_server;
root /var/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
我想從我的子域http://mydomain.com/wordpress加載wordpress。 我繼續修改位置,但是無法正確加載(它仍然在http://mydomain.com下查找文件)。
root /var/www;
index index.php index.html index.htm;
location /wordpress {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
要么
location /{
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}
我該如何解決? 謝謝
您的wordpress在根目錄中查找他的文件。 /所以您需要告訴他,在正確的目錄中搜索他的文件。 / wordpress /有兩種方法。 更好:使用wordpress配置文件更改路徑以重寫資源路徑
從
/css/*, /* etc
至
/wordpress/css/*, /wordpress/* and so on.
最差:將您的wordpress資源重定向到根目錄。 像這樣:
location ~ ^/images/(.*)$ {
try_files $uri /wordpress/images/$uri =404;
access_log off;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.