WordPress 3.0 및 nginx - permalink, 404 문제
서버에 nginx, Fast CGI 및 PHP를 설치했습니다.WordPress 3.0은 몬스터 전투 후에 설치되었지만 설치 및 작동 상태가 양호합니다.
단, permalink 설정을 디폴트 이외의 설정으로 변경하면, 투고, 기사, 페이지 마다 404 에러가 발생합니다.
이것은 nginx가 .htaccess를 지원하지 않는 것과 WordPress가 페이지를 필요로 할 때 어디로 가야 할지 헷갈리는 것과 관련이 있는 것으로 알고 있습니다.
nginx conf 파일과 nginx 호환성 플러그인으로 몇 번 다시 쓰기를 시도했지만 둘 다 작동하지 않았습니다.한 번의 개서로 404 오류를 막을 수 있었지만, WordPress 대신 PHP 확인 페이지를 받은 후에 게시물을 찾았습니다.아아아~
포럼에는 비슷한 문제를 가진 사람들이 흩어져 있다.해결책을 가진 사람이 있나요?
고객님의 위치/블록에서
이를 추가하고 특정되지 않은 개서 규칙을 삭제합니다.
try_files $uri $uri/ /index.php;
워드프레스가 루트 이외의 다른 디렉토리에 있는 경우
if (!-e $request_filename) {
rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last;
}
다음과 같은 것이 있습니다.
location /wordpress {
try_files $uri $uri/ /wordpress/index.php?$args;
}
이 페이지의 컨셉은 완전히 동일합니다.먼저 읽고 시도했어야 했다: 서브디렉토리 아래의 nginx rewrite rule
고심 끝에:
# if filename doesn't exist, take the request and pass to wordpress as a paramater
if (!-e $request_filename) {
rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last;
}
요청된 파일이 존재하지 않으면 index.php로 전달합니다.조금 느리고 쿼리를 사용하지 않을 수도 있지만 작동은 합니다.:)
nginx Compatibility 플러그인을 사용해 보셨습니까?
게다가 Elastic Dog는 WP가 nginx와 제휴하는 것에 관한 꽤 간결한 기사를 제공하고 있는 것 같다.이것은 꽤 퍼머링크가 기능하도록 하는 것을 포함한다.
여기 WordPress의 nginx rewrite rules에 대한 또 다른 기사가 있습니다.
이게 내가 드림호스트에 있는 워드프레스 블로그에 있는 퍼머링크를 해결한 방법이야
폴더 내부/home/ftpusername/nginx/example.com/
(없으면 작성해주세요)
다음 내용으로 nginx.conf 파일을 만들었습니다.
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
nginx를 재기동했다.
/etc/init.d/nginx 새로고침
주의사항:
시스템에 따라 ftpusername 및 example.com을 변경해야 합니다.
바로 그거였어!
모두 행운을 빌어요.
다음 장소 이외의 장소를 사용하고 있는 경우는, 이 기능은 동작하지 않습니다.
~ .tv$, 예쁜 링크는 작동하지만 그래픽은 도처에 널려있습니다.그래서 당신이 필요한 것은 정확히 아래에 기재되어 있습니다.
location ~ \.php$
{
try_files $uri $uri/ /index.php?$uri&$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?url=$1 break;
}
나는 다음과 같이 했다.
/home/userrunningginx/nginx/domain.com 폴더에 있습니다.
다음과 같은 것이 있습니다.
default.conf(파일)
include /home/neukbaarofnietps/nginx/neukbaarofniet.com/drop;
드롭(파일)
# Rather than just denying .ht* in the config, why not deny
# access to all .invisible files
location ~ /\. { deny all; access_log off; log_not_found off; }
nginx.conf (파일)
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
WORDPRESS-NGINXCONF(파일)
#######################
# WP Super Cache
# if the requested file exists, return it immediately
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri '';
}
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host$1/index.html;
}
# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# all other requests go to Wordpress
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
이 블록을 nginx.conf에 추가하면 문제가 해결됩니다.
if (!-e $request_filename) {
rewrite ^/wordpress_dir/(.+)$ /wordpress_dir/index.php?q=$1 last;
}
이게 도움이 됐으면 좋겠다.
행운을 빌어요.
언급URL : https://stackoverflow.com/questions/3255446/wordpress-3-0-nginx-permalink-404-problem
'it-source' 카테고리의 다른 글
날짜 스탬프 파일을 정리하려면 Logrotate (0) | 2023.03.12 |
---|---|
async componentDidMount()를 사용하는 것은 좋은 것입니까? (0) | 2023.03.12 |
Word press는 기본 역할 제거 및 사용자 지정 역할 추가 (0) | 2023.03.12 |
데이터베이스로서의 NoSQL(MongoDB) vs Lucene(또는 Solr) (0) | 2023.03.12 |
Word press를 통해 사용자 ID 가져오기 (0) | 2023.03.12 |