본문으로 바로가기

apache 에서 redirect (rewrite 모듈)

category [ Web 관련 ]/php 2020. 10. 21. 11:33

(apache 레벨에서 redirect)

 

 

- 모듈 설치 확인

# ls /etc/httpd/modules/

mod_rewrite.so  확인

 

- 아파치 설정 파일에 모듈 로드 코드 확인(주석이라면 주석해제)

#vi /etc/httpd/conf/httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so

 

- <?=phpinfo()?>의 Loaded Modules 에서 확인

mod_rewrite

 

 

 

 

redirect 설정

www.test1.com:8080 의 특정 페이지를 호출하면, www.test2.com:8080 의 해당 페이지를 호출

GET 으로 전달되는 파라미터도 사용가능

POST방식은 사용 불가

 

#vi /etc/httpd/conf/httpd.conf
#port로 구분해서 사용 할 경우

<VirtualHost *:8080>
   ServerName www.test1.com 
 
   Header always set Access-Control-Allow-Origin "*"
   Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
   Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location, Content-Type"
   Header always set Access-Control-Max-Age "600"

   RewriteEngine On
   RewriteRule (.*) http://www.test2.com:8080%{REQUEST_URI}  [R,L]
</VirtualHost>

 

 

 

 

 

 

 

'[ Web 관련 ] > php' 카테고리의 다른 글

php 5.x 와 php 7.x 이슈  (0) 2020.11.11
php, mysql 테이블 존재 확인  (0) 2020.11.02
php 어제 날짜 구하기  (0) 2020.09.02
변수 타입 확인하기  (0) 2020.07.03
excel upload 샘플  (0) 2020.05.21