NGINX 워드프레스 고유주소를 위한 가상호스트 설정

NGINX

워드프레스는 고유주소(Permalink)를 지원하여 도메인 주소 뒤에 붙는 포스트 페이지 쿼리인 ?p= 대신 포스트 번호나 포스트 이름등을 출력하고 카테고리, 태그 등을 주소 하위 디렉토리 구조로 보여줄 수 있습니다.

아파치 같은 경우 .htaccess 안에 rewrite 구문이 추가되며 이 rule을 기반으로 고유주소를 동작할수 있게 하는데 NGINX 같은 경우에는 가상호스트에서 관리자가 직접 설정을 해야 합니다.

server {
        listen 80;
        server_name domain.com www.domain.com;
        root /home/사용자계정/www;
        access_log /home/사용자계정/www/log/domain.com-access.log main;
        index index.html index.htm index.php;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        }
        location = /\. { deny all; access_log off; log_not_found off; }
}

location /블럭에 위와 같이 설정한 다음 NGINX를 재시작합니다.

1

워드프레스 관리자 메뉴의 설정 > 고유주소에서 원하는 양식의 구조를 지정한 다음 저장하면 되겠습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Fill out this field
Fill out this field
유효한 이메일 주소를 입력해주세요.