미디어위키 간편URL 적용 편집하기

경고: 로그인하지 않았습니다. 편집을 하면 IP 주소가 공개되게 됩니다. 로그인하거나 계정을 생성하면 편집자가 사용자 이름으로 기록되고, 다른 장점도 있습니다.

편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.

최신판 당신의 편집
1번째 줄: 1번째 줄:
==개요==
;미디어위키 단축 URL 사용, 미디어위키 단축 주소
;미디어위키 짧은 URL 적용, 미디어위키 짧은 주소 적용
*http://도메인/wiki/표제어 형식의 URL을 사용할 수 있도록 함


==미디어위키 폴더 이름 변경==
==미디어위키 폴더 이름 변경==
[[미디어위키 폴더]] 이름이 w가 아니었다면 w로 변경 (여기서는 mediawiki 이었던 예시)
[[미디어위키 폴더]] 이름이 w가 아니었다면 w로 변경 (여기서는 mediawiki인 예시)
<syntaxhighlight lang='console'>
<source lang='dos'>
[root@zetawiki html]# ll
[root@jmnote www]# ll
... (생략)
... (생략)
drwxr-xr-x 16 root root  4096 Aug 16 17:58 mediawiki
drwxr-xr-x 16 root root  4096 Aug 16 17:58 mediawiki
[root@zetawiki html]# mv mediawiki w
[root@jmnote www]# mv mediawiki w
[root@zetawiki html]# ll
[root@jmnote www]# ll
... (생략)
... (생략)
drwxr-xr-x 16 root root  4096 Aug 16 17:58 w
drwxr-xr-x 16 root root  4096 Aug 16 17:58 w
</syntaxhighlight>
</source>


==[[LocalSettings.php]] 수정==
==[[LocalSettings.php]] 수정==
{{소스헤더|수정 전}}
;수정 전
<syntaxhighlight lang='php'>
<source lang='php'>
$wgScriptPath      = "/mediawiki";
$wgScriptPath      = "/mediawiki";
$wgScriptExtension  = ".php";
$wgScriptExtension  = ".php";
</syntaxhighlight>
</source>


{{소스헤더|수정 후}}
;수정 후
<syntaxhighlight lang='php'>
<source lang='php'>
$wgScriptPath      = "/w";
$wgScriptPath      = "/w";
$wgScript          = "$wgScriptPath/index.php";
$wgScript          = "$wgScriptPath/index.php";
$wgArticlePath      = "/wiki/$1";
$wgArticlePath      = "/wiki/$1";
$wgScriptExtension  = ".php";
$wgScriptExtension  = ".php";
</syntaxhighlight>
</source>
 
==httpd.conf 수정==
==방법1: httpd.conf 수정 및 아파치 재시작==
*[[httpd.conf]] 파일에 DocumentRoot 행 아래에 내용 추가. (DocumentRoot 줄 자체는 수정하면 안됨.)
*[[httpd.conf]] 파일의 DocumentRoot 행 아래에 내용 추가. (DocumentRoot 줄 자체는 수정하면 안됨.)
*아래 예시는 DocumentRoot가 /var/www일 때의 예시이다. 만약 다르다면 /var/www 부분을 모두 찾아 DocumentRoot 값에 맞게 바꿔줘야 한다.
*아래 예시는 [[DocumentRoot]]가 /var/www/html일 때의 예시이다. 만약 다르다면 /var/www/html 부분을 모두 찾아 DocumentRoot 값에 맞게 바꿔줘야 한다.
<source lang='bash'>
<syntaxhighlight lang='bash'>
# DocumentRoot: The directory out of which you will serve your
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
# symbolic links and aliases may be used to point to other locations.
#
#
DocumentRoot "/var/www/html"
DocumentRoot "/var/www"
#RedirectMatch /mediawiki/index.php/(.*)$ http://jmnote.com/wiki/$1
#RedirectMatch /mediawiki/index.php/(.*)$ http://jmnote.com/wiki/$1
#RedirectMatch /mediawiki/index.php?(.*)$ http://jmnote.com/w/index.php?$1
#RedirectMatch /mediawiki/index.php?(.*)$ http://jmnote.com/w/index.php?$1
#RedirectMatch /mediawiki/images/(.*)$ http://jmnote.com/w/images/$1
#RedirectMatch /mediawiki/images/(.*)$ http://jmnote.com/w/images/$1
Alias /wiki /var/www/html/w/index.php
Alias /wiki /var/www/w/index.php
Alias /index.php /var/www/html/w/index.php
Alias /index.php /var/www/w/index.php
Alias /w/skins/ /var/www/html/w/skins/
Alias /w/skins/ /var/www/w/skins/
Alias /w/images/ /var/www/html/w/images/
Alias /w/images/ /var/www/w/images/
</syntaxhighlight>
</source>
:→ RedirectMatch는 기존 주소<ref>http://도메인/mediawiki/index.php/표제어</ref>를 새 주소<ref>http://도메인/wiki/표제어</ref>로 포워딩해주는 역할을 한다. (새 사이트 구축시는 필요 없다.)
:→ RedirectMatch는 기존 주소<ref>http;//도메인/mediawiki/index.php/표제어</ref>를 새 주소<ref>http;//도메인/wiki/표제어</ref>로 포워딩해주는 역할을 한다.
:→ 새 사이트 구축시는 필요 없다.
:→ 검색엔진에 등록된 기존 주소가 끊어지지 않도록 하려면 RedirectMatch 3줄 주석 해제.<ref>물론 jmnote.com은 자신의 도메인으로 바꿔주시라.</ref>
:→ 검색엔진에 등록된 기존 주소가 끊어지지 않도록 하려면 RedirectMatch 3줄 주석 해제.<ref>물론 jmnote.com은 자신의 도메인으로 바꿔주시라.</ref>


*[[아파치 재시작]]
==[[아파치 재시작]]==
<syntaxhighlight lang='console'>
<source lang='dos'>
[root@zetawiki html]# service httpd restart
[root@jmnote www]# service httpd restart
Stopping httpd:                                            [  OK  ]
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
</syntaxhighlight>
</source>
 
==방법2: .htaccess 파일 작성==
( httpd.conf 파일을 수정할 수 없는 경우 등 )
[[미디어위키 폴더]]의 [[.htaccess 파일]]을 수정<ref>없으면 신규작성</ref>한다.<ref>http://techwelkin.com/mediawiki-urls-short-clean-and-beautiful</ref>
<syntaxhighlight lang='aconf'>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}${RQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}${RQUEST_URI} !-d
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/w/index.php [L]
</syntaxhighlight>
 
==(Optional, 윈도우) 한글 제목 문서가 깨지는 현상 해결법==
테스트 환경 : Windows 10, IIS(URL Rewrite 2.0, Mediawiki 1.30.0, php-7.2.3
 
'''Language.php''' 파일의 '''checkTitleEncoding''' 부분 코드를 수정해서 해결가능.(Line 2794)
여기서 UHC(Unified Hangul Codeset)는 CP949(한글 인코딩)을 의미한다.
영어 외의 모든 언어에 대해서 이렇게 해주기는 어렵겠지만 임시방편으로는 유용하게 쓸 수 있을 것 같다.
 
<syntaxhighlight lang='php'>
/**
* @param string $s
* @return string
* @throws MWException
*/
function checkTitleEncoding( $s ) {
if ( is_array( $s ) ) {
throw new MWException( 'Given array to checkTitleEncoding.' );
}
if ( StringUtils::isUtf8( $s ) ) {
return $s;
}
 
# ADDED for Korean Language Support
if( mb_detect_encoding($s, "UHC") ) {
return $this->iconv( "UHC", 'utf-8', $s );
}
 
return $this->iconv( $this->fallback8bitEncoding(), 'utf-8', $s );
}
</syntaxhighlight>


==같이 보기==
==주석==
*[[미디어위키 index.php 연결]]
<references/>
*[[미디어위키 커스터마이징]]
*[[미디어위키 pageid URL]]
*[[그누보드 간편URL 적용]]
*[[단축 URL]]


==참고==
==참고 자료==
*https://www.mediawiki.org/wiki/Manual:Short_URL
*https://www.mediawiki.org/wiki/Manual:Short_URL


[[분류: 미디어위키]]
[[분류: 미디어위키]]
[[분류: URL]]
[[분류: URL]]

제타위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-동일조건변경허락 3.0 라이선스로 배포된다는 점을 유의해 주세요(자세한 내용에 대해서는 제타위키:저작권 문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요.
또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다. 저작권이 있는 내용을 허가 없이 저장하지 마세요!

취소 편집 도움말 (새 창에서 열림)

이 문서에서 사용한 틀: