Nginx - 하위 디렉토리의 워드프레스, 어떤 데이터를 전달해야 합니까?
여러 가지 시도를 해봤어요.내가 지금 하고 싶은 말은 이거야
location ^~ /wordpress {
alias /var/www/example.com/wordpress;
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/index.php;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(/wordpress)(/.*)$;
fastcgi_param SCRIPT_FILENAME /var/www/example.com/wordpress/index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
현재 제가 알 수 있는 한 모든 리소스(이미지 등)가 올바르게 로드되고 있습니다.그리고.http://www.example.com/wordpress워드프레스를 로드하지만 페이지가 "page not found"로 표시됩니다(단, 워드프레스는 이 경우에 사용됩니다).투고 URL을 시도해도 같은 결과가 나타납니다.「 page not found 」워드프레스가 경로에 대한 데이터를 얻지 못하는 게 문제라는 걸 알아요또 다른 잠재적인 문제는 만약 내가 도망친다면example.com/wp-admin.php그러면 그것은 계속 실행된다.index.php.
어떤 데이터를 전달해야 합니까?여기서 무슨 일이 일어나고 있는 걸까요?
로케이션 에일리어스 엔드가 일치하므로 root만 사용해야 합니다.또한 모든 것이 wordpress afaik의 index.php를 통해 라우팅되는 것은 아닙니다.또, 패스 정보가 필요한 것을 모르는 한, 아마 필요 없을 것입니다.내 생각에 당신은 다음과 같은 것을 원하는 것 같다:
location @wp {
rewrite ^/wordpress(.*) /wordpress/index.php?q=$1;
}
location ^~ /wordpress {
root /var/www/example.com;
index index.php index.html index.htm;
try_files $uri $uri/ @wp;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass 127.0.0.1:9000;
}
}
또는 경로 정보가 꼭 필요한 경우(/wordpress/index.dex/foo/bar와 같이 표시됨):
location ^~ /wordpress {
root /var/www/example.com;
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/index.php;
location ~ \.php {
fastcgi_split_path_info ^(.*\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
}
}
편집: 첫 번째 서버{}가 업데이트되어 uri에서 첫 번째 /wordpress를 제거하고 나머지를 q 파라미터로 전달
EDIT2: 이름 있는 위치는 서버 레벨에서만 유효합니다.
야, 이건 마젠토 루트 폴더의 하위 디렉토리에 있는 워드프레스 블로그에 효과가 있을 거야!
server {
listen 80;
server_name my-site.co.uk;
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
}
server {
listen 80 default;
client_max_body_size 8M;
## SSL directives might go here
server_name www.my-site.co.uk; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/my-site/magento;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
location /wordpress {
index index.php index.html index.htm;
try_files $uri $uri/ /wordpress/index.php;
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
저도 같은 문제가 있었고, 이렇게 해결했습니다.
사이트의 NGINX 컨피규레이션파일을 엽니다.서버 블록 내에서 루트 디렉토리에 경로를 추가하고 파일의 우선순위를 설정합니다.
root /mnt/www/www.domainname.com; index index.php index.html index.htm;다른 모든 위치 블록보다 먼저 빈 위치 블록을 만듭니다.
location /latest { # Nothing in here; this is to avoid redirecting for this location }위치/블록에 있는 루트 디렉토리를 추천하고 다음과 같이 리다이렉션을 추가합니다.
location / { # root /mnt/www/www.domainname.com; index index.php index.html index.htm; rewrite ^/(.*)$ http://www.domainname.com/latest/$1 redirect; }위치 ~ .php$ 블록이 루트를 가리키는지 확인합니다.
root /mnt/www/www.domainname.com;
이것으로 나는 해결되었다.
언급URL : https://stackoverflow.com/questions/6154879/nginx-wordpress-in-a-subdirectory-what-data-should-be-passed
'source' 카테고리의 다른 글
| 리액트 타입 스크립트프로젝트에서의 react-app-env.d.ts의 용도는 무엇입니까? (0) | 2023.03.29 |
|---|---|
| 대응: 키보드 이벤트 핸들러 모든 '특수' (0) | 2023.03.29 |
| 2개의 php 어레이 - 하나의 어레이를 다른 어레이의 값 순서로 정렬합니다. (0) | 2023.03.29 |
| 축척된 div의 끌 수 있는 요소에 대한 정확한 드롭 (0) | 2023.03.29 |
| Angular2 오류:"exportAs"가 "ngForm"으로 설정된 지시문이 없습니다. (0) | 2023.03.29 |