[linux] mod_url.c (한글 URL 처리 모듈) 설치방법

페이지 정보

작성자 로빈아빠
댓글 0건 조회 7,649회 작성일 09-12-11 12:51


mod_url.c (한글 URL 처리 모듈) 설치방법
브라우저에서 주소창에서 한글URL 또는 웹페이지상의 한글로된 이미지 파일이 처리가 제데로 되지 않아서 깨져 보일때.
아래의 모듈을 쓰면 해결이 됨니다.

mod_url.c의  설치 방법은 다음과 같습니다.

1. DSO 확인
# httpd -l
Compiled-in modules:
#/usr/local/apache/bin/httpd -l | grep mod_so

여기서 mod_so.c 가 보이면 DSO를 통해 간편하게 mod_url.c를 설치할 수 있습니다.

2. 컴파일(일반적인 경우 RedHat은 아래 참조)
설치는 아파치 확장 툴인 apxs를 이용합니다.
# apxs -i -a -c mod_url.c
이렇게 실행하면 됩니다.
# apxs -i -a -c mod_url.c
gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_url.c
ld -Bshareable -o mod_url.so mod_url.o
cp mod_url.so /path_to/apache/libexec/mod_url.so
chmod 755 /path_to/apache/libexec/mod_url.so
[activating module `redurl' in /path_to/apache/etc/httpd.conf]

vi /usr/local/apache/conf/httpd.conf 파일을 열어보시면
아래 부분이 생성이 될것입니다.
LoadModule redurl_module      libexec/mod_url.so
AddModule mod_url.c
<IfModule mod_url.c>
        CheckURL On
위의 mod_url.c 는 다음에 올린 글을 참고하셔서 복사하신후에
# chmod 700 mod_url.c
# /usr/local/apache/bin/apxs -i -a -c mod_url.c
하시면 됩니다.

mod_url.c는 사이트를 참고하셔서 전체 복사하신후 vi에서 붙여넣기 하시고,
쓰시면 됩니다.
사이트 : http://tunelinux.pe.kr/wikix/file/Web/mod_url.c

#define WANT_BASENAME_MATCH /* ====================================================================  * Copyright (c) 1996-1999 The Apache Group. All rights reserved.  *  * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions  * are met:  *  * 1. Redistributions of source code must retain the above copyright  * notice, this list of conditions and the following disclaimer.  *  * 2. Redistributions in binary form must reproduce the above copyright  * notice, this list of conditions and the following disclaimer in  * the documentation and/or other materials provided with the  * distribution.  *  * 3. All advertising materials mentioning features or use of this  * software must display the following acknowledgment:  * "This product includes software developed by the Apache Group  * for use in the Apache HTTP server project (http://www.apache.org/)."  *  * 4. The names "Apache Server" and "Apache Group" must not be used to  * endorse or promote products derived from this software without  * prior written permission. For written permission, please contact  * apache@apache.org.  *  * 5. Products derived from this software may not be called "Apache"  * nor may "Apache" appear in their names without prior written  * permission of the Apache Group.  *  * 6. Redistributions of any form whatsoever must retain the following  * acknowledgment:  * "This product includes software developed by the Apache Group  * for use in the Apache HTTP server project (http://www.apache.org/)."  *  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  * OF THE POSSIBILITY OF SUCH DAMAGE.  * ====================================================================  *  * This software consists of voluntary contributions made by many  * individuals on behalf of the Apache Group and was originally based  * on public domain software written at the National Center for  * Supercomputing Applications, University of Illinois, Urbana-Champaign.  * For more information on the Apache Group and the Apache HTTP server  * project, please see <http://www.apache.org/>.  *  */ #include "httpd.h" #include "http_core.h" #include "http_config.h" #include "http_log.h" #include <iconv.h> /* mod_url.c - by Won-kyu Park <wkpark@chem.skku.ac.kr>  *  * based mod_speling.c Alexei Kosut <akosut@organic.com> June, 1996  *  * Activate it with "CheckURL encoding On"  */ MODULE_VAR_EXPORT module redurl_module; typedef struct { int enabled; } urlconfig; /*  * Create a configuration specific to this module for a server or directory  * location, and fill it with the default settings.  *  * The API says that in the absence of a merge function, the record for the  * closest ancestor is used exclusively. That's what we want, so we don't  * bother to have such a function.  */ static void *mkconfig(pool *p) { urlconfig *cfg = ap_pcalloc(p, sizeof(urlconfig)); cfg->enabled = 0; return cfg; } /*  * Respond to a callback to create configuration record for a server or  * vhost environment.  */ static void *create_mconfig_for_server(pool *p, server_rec *s) { return mkconfig(p); } /*  * Respond to a callback to create a config record for a specific directory.  */ static void *create_mconfig_for_directory(pool *p, char *dir) { return mkconfig(p); } /*  * Handler for the CheckURL encoding directive, which is FLAG.  */ static const char *set_redurl(cmd_parms *cmd, void *mconfig, int arg) { urlconfig *cfg = (urlconfig *) mconfig; cfg->enabled = arg; return NULL; } /*  * Define the directives specific to this module. This structure is referenced  * later by the 'module' structure.  */ static const command_rec redurl_cmds[] = { { "CheckURL", set_redurl, NULL, OR_OPTIONS, FLAG, "whether or not to fix mis-encoded URL requests" }, { NULL } }; static int check_redurl(request_rec *r) { urlconfig *cfg; char *good, *bad, *postgood, *url; int filoc, dotloc, urlen, pglen; DIR *dirp; struct DIR_TYPE *dir_entry; array_header *candidates = NULL; cfg = ap_get_module_config(r->per_dir_config, &redurl_module); if (!cfg->enabled) { return DECLINED; } /* We only want to worry about GETs */ if (r->method_number != M_GET) { return DECLINED; } /* We've already got a file of some kind or another */ if (r->proxyreq || (r->finfo.st_mode != 0)) { return DECLINED; } /* This is a sub request - don't mess with it */ if (r->main) { return DECLINED; } /* * The request should end up looking like this: * r->uri: /correct-url/mispelling/more * r->filename: /correct-file/mispelling r->path_info: /more * * So we do this in steps. First break r->filename into two pieces */ filoc = ap_rind(r->filename, '/'); /* * Don't do anything if the request doesn't contain a slash, or * requests "/" */ if (filoc == -1 || strcmp(r->uri, "/") == 0) { return DECLINED; } /* good = /correct-file */ good = ap_pstrndup(r->pool, r->filename, filoc); /* bad = mispelling */ bad = ap_pstrdup(r->pool, r->filename + filoc + 1); /* postgood = mispelling/more */ postgood = ap_pstrcat(r->pool, bad, r->path_info, NULL); urlen = strlen(r->uri); pglen = strlen(postgood); /* Check to see if the URL pieces add up */ if (strcmp(postgood, r->uri + (urlen - pglen))) { return DECLINED; } /* url = /correct-url */ url = ap_pstrndup(r->pool, r->uri, (urlen - pglen)); /* 시작 */ ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r, "Orig URL: %s %s url:%s", r->uri, good, url); { static iconv_t cd = 0; // const char *src = "안녕하세요"; // const char *src = "


등록된 댓글이 없습니다.