워드프레스 고유주소 (permalink)를 글 이름 으로 변경시 에러에 대한 해결방법을 소개합니다. 블로그의 고유주소는 의미있는 URL을 제공함으로써 사용자와 검색 엔진 모두에게 포스팅 내용에 대한 힌트를 주며 중복 컨텐츠를 방지하는 효과를 주기때문에 SEO에 매우 중요한 요소이므로 오류를 꼭 해결해야 합니다. 특히 AWS의 아마존 리눅스 2023 서버를 사용하면서 워드프레스를 처음 개설한 경우 이런 오류가 많이 나오게 되는데 이 포스팅의 해결방법이 도움이 되리라 생각합니다.
[함께 보면 좋은 글 추천]
1. 워드프레스 고유주소 변경 방법
먼저 워드프레스의 고유주소를 SEO에 친화적이도록 글 이름으로 변경합니다.
관리자 페이지의 ①설정에서 ②고유주소에 들어가서 ③글 이름으로 변경해 줍니다.
2. 워드프레스 고유주소 변경 에러 해결 방법
1. .htaccess 파일의 그룹 및 권한 설정 변경
먼저, Xshell이나 Termius 프로그램을 통해 SSH에 접속하여 .htaccess 파일의 그룹과 권한 설정을 변경해 주어야 합니다. .htaccess 파일은 Apache 웹 서버에서 사용하는 구성 파일로 웹 사이트의 특정 부분의 구성을 변경할때 수정해야 하는 파일입니다. 우리는 URL 재작성을 통해 고유주소(permalink)를 글 이름으로 변경해야 하므로 .htaccess 파일에 관리자로 접근하여 수정해야 하는 것입니다.
단, 실행전 주의사항은 .htaccess 파일의 설정이 잘못되었을 경우 웹사이트의 동작이 멈추기 때문에 반드시 백업을 한 후 진행하시기 바랍니다.
아래의 명령어를 입력하여 파일의 소유자와 그룹을 변경해 줍니다.
cd /var/www/html
sudo chown ec2-user:apache .htaccess
sudo chmod 644 .htaccess
설명: cd /var/www/html를 통해 워드프레스가 설치되어 있는 경로로 이동합니다. sudo chown ec2-user:apache .htaccess명령어는 Linux 환경에서 파일 또는 디렉토리의 소유권을 변경하는 chown
명령어를 사용하여 .htaccess
파일의 소유자와 그룹을 변경합니다.
한마디로, .htaccess
파일의 소유자를 ec2-user
로, 그룹을 apache
로 변경하라는 의미입니다.
그리고 sudo chmod 644 .htaccess
명령어를 통해 “.htaccess 파일의 권한을 소유자에게 읽기 및 쓰기 권한을 부여하고, 그룹과 다른 사용자에게는 읽기 권한만 부여해 줍니다.
이제 .htaccess 파일은 오직 사용자만 편집할 수 있게 되었습니다.
2. FTP 클라이언트 프로그램으로 .htaccess 파일에 액세스
이제 .htaccess 파일에 들어가기 위해 FTP 클라이언트 프로그램을 이용해야 하는데 가장 많이 사용되는 파일질라(FileZilla) 프로그램을 사용하겠습니다.
저의 .htaccess 파일은 현재 ‘/var/www/html’ 경로에 있습니다. 아래와 같이 .htaccess 파일을 우 클릭 해서 편집 및 보기를 선택하여 편집 모드로 들어갑니다.
이제 .htaccess 파일에 아래의 코드를 복사하여 붙여넣어 줍니다.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
설명: 이 설정은 실제로 존재하는 파일 또는 디렉토리를 요청하는 경우를 제외하고 모든 웹 요청을 워드프레스의 ‘index.php’ 파일로 전달하고 이를 통해 워드프레스는 적절한 페이지난 게시물을 찾아 출력하게 됩니다. 아래는 코드 상세 설명입니다.
<IfModule mod_rewrite.c>
…</IfModule>
:mod_rewrite
모듈이 로드되어 있는 경우에만 괄호 안의 코드를 실행합니다.mod_rewrite
는 Apache 웹 서버에서 URL 재작성을 가능하게 하는 모듈입니다.
RewriteEngine On
:- URL 재작성 기능을 활성화합니다.
RewriteBase /
:- 재작성되는 URL의 기본 경로를 설정합니다. 여기서는 웹사이트의 루트 디렉토리를 의미합니다.
RewriteRule ^index\.php$ - [L]
:- 만약 URL이
index.php
로 끝난다면, 아무 것도 하지 않고 (즉,-
로 표시된 “no substitution”) 현재의 규칙 처리를 멈춥니다([L]
플래그).
- 만약 URL이
RewriteCond %{REQUEST_FILENAME} !-f
:- 요청된 파일 이름이 실제로 존재하는 파일이 아닌 경우에만 다음 규칙을 적용합니다.
RewriteCond %{REQUEST_FILENAME} !-d
:- 요청된 파일 이름이 실제로 존재하는 디렉토리가 아닌 경우에만 다음 규칙을 적용합니다.
RewriteRule . /index.php [L]
:- 위의 조건들이 모두 만족되면, 모든 요청을
index.php
로 리다이렉트합니다.[L]
플래그는 다른 재작성 규칙을 더 이상 처리하지 않도록 합니다.
- 위의 조건들이 모두 만족되면, 모든 요청을
3. Apache 설정 파일 편집
sudo nano /etc/httpd/conf/httpd.conf
설명: 위 명령어로 Apache의 설정 파일을 열어 줍니다.
4. 고유주소(permalink)의 설정 변경
Include conf.modules.d/*.conf
LoadModule rewrite_module modules/mod_rewrite.so
설명: Apache의 설정 파일에서 mod_rewrite 모듈을 활성화 시켜줍니다.
5. 웹 서버의 루트 디렉토리에 대한 권한을 구성
AllowOverride 및 Require 지시문을 사용하여 웹 서버의 루트 디렉토리에 대한 권한을 구성합니다. 워드프레스의 고유주소를 글 이름으로 변경해도 에러가 나지 않게 하려면 다음과 같이 수정합니다.
(혹시 오류가 생기면 LoadModule rewrite_module modules/mod_rewrite.so
이 부분을 삭제하면 괜찮아지는 경우가 있으니 참고해 주세요.)
<Directory />
AllowOverride All
Require all granted
</Directory>
<Directory “/var/www”>
AllowOverride All
# Allow open access: Require all granted
</Directory>
<Directory “/var/www/html”>
AllowOverride All
Require all granted
</Directory>
<Directory “/var/www/추가 워드프레스가 설치 된 폴더명”>
AllowOverride All
Require all granted
</Directory>
<Files “.ht*”>
Require all granted
</Files>
<Directory “/var/www/cgi-bin”>
AllowOverride All
Options None
Require all granted
</Directory>
서버에 다수의 워드프레스가 설치되어 있는 경우 위의 ‘추가 워드프레스가 설치 된 폴더명’ 이하 명령어를 입력하여 추가하면 되겠습니다.
이제, Apache의 설정 파일의 수정이 모두 끝났으니 Ctrl+o로 설정을 저장후 Enter를 누르고 Ctrl +X로 에디터를 종료하겠습니다.
6. Apache 웹 서버 재시작
Apache 웹 서버를 다시 시작하여 변경 사항을 적용해 줍니다.
sudo systemctl restart httpd
이것으로 워드프레스 고유주소 변경 에러에서 해방되실 수 있습니다.
My brother suggested I would possibly like this website.
He was totally right. This submit actually made my day.
You cann’t imagine simply how so much time I had
spent for this info! Thank you!
Today, I went to the beach front with my kids.
I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this is completely off topic but
I had to tell someone!
Your style is so unique in comparison to other people I have read stuff from.
Many thanks for posting when you’ve got the opportunity, Guess I will just bookmark this page.
Hello there, I think your website could possibly be having web browser compatibility problems.
When I look at your site in Safari, it looks fine however, if opening in Internet Explorer,
it’s got some overlapping issues. I merely wanted to give you a quick
heads up! Apart from that, fantastic blog!
Wow that was strange. I just wrote an extremely long comment but after I clicked submit my comment didn’t show up.
Grrrr… well I’m not writing all that over again. Anyhow,
just wanted to say great blog!
Its like you read my mind! You seem to know so much about this,
like you wrote the book in it or something. I think that you can do with a few pics to drive
the message home a bit, but other than that, this is excellent blog.
A great read. I will definitely be back.