티스토리 뷰
mod_rewrite 예제
도메인 요청 URL 에서 특정 가변적인 문자열 (아이디) 를 추출해서 서브도메인으로 만들고 나머지 요청은 그대로 유지
test.kensei.co.kr/webdev/takakocap/data/index.html (입력) --> takakocap.kensei.co.kr/data/index.html (변환)
|
데이터 정의
test.kensei.co.kr --> 도메인 (값 고정) /webdev --> 디렉토리 (값 고정) /takakocap --> 디렉토리 (유저ID) (값 가변) /data/index.html --> 유저 ID 디렉토리 이후 나머지 요청 (값 가변)
|
해결
RewriteEngine on RewriteLog "/etc/httpd/logs/rewrite.log" RewriteLogLevel 9 RewriteCond %{REQUEST_URI} /webdev/[a-zA-Z0-9]+/ [NC] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.com) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.net) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.org) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.biz) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.info) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.co.kr) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.or.kr) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.pe.kr) [OR] RewriteCond %{SERVER_NAME} ([a-zA-Z0-9]+\.kr) RewriteRule ^(.*)/webdev/([^/\.]+)/(.*)$ http://$2.%1/$3 [P,L] RewriteRule ^(.*)/webdev/([^/\.]+)/(.*)$ https://$2.%1/$3 [P,L]
|
/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 takakocap.kensei.co.kr takakocap.kensei.com takakocap.kensei.net takakocap.kensei.or.kr
|
'WEB' 카테고리의 다른 글
| [mpm_prefork:error] [pid 10161] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting (0) | 2017.10.12 |
|---|---|
| 워드프레스 구버젼 (옜날 버전) 설치하기 (0) | 2017.09.29 |
| Let'sEncrypt 명령어 하나로 셋팅하기 (1) | 2017.09.07 |
| 워드프레스 이커머스 (Electronic Commerce) (0) | 2017.05.24 |
| cookie 보안 취약점 (0) | 2017.03.16 |
- Total
- Today
- Yesterday
- php
- ssh
- ntp
- centos8
- 리눅스
- SSL
- cURL
- HAProxy
- GeoIP
- WAF
- yum
- softether
- glusterfs
- OpenVPN
- mod_security
- MySQL
- kvm
- galera
- mariadb
- L2TP
- gitlab
- pptp
- Apache
- centOS7
- 인증서
- iptables
- 베이어다이나믹
- virtualbox
- IPSEC
- NGINX
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
