작성일 댓글 남기기

[서버] 아파치 rewrite 설정 참고 문서

문서 복사 내용. 원본 링크는 아래 링크들 참고

$ sudo a2enmod rewrite 
$ sudo systemctl restart apache2
<VirtualHost *:80>
#ServerName hiseon.me 
ServerAdmin webmaster@hiseon.me 
DocumentRoot /var/www/html 
ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 
<Directory /var/www/html/> 
Options Indexes FollowSymLinks 
AllowOverride All 
Require all granted 
</Directory> 
</VirtualHost>

https://hiseon.me/server/apache-rewrite-examples/

MOD_REWRITE로 URL 다루기

https://www.lesstif.com/linux-infra-book/mod_rewrite-url-18219493.html

아차피 모드 rewrite 예제

https://m.blog.naver.com/PostView.nhn?blogId=budget74&logNo=90105393852&proxyReferer=https:%2F%2Fwww.google.com%2F

★**********************진짜 참고가 잘되었던 문서 예제 ******************************************

1. tmax1.tmax.co.kr로 들어오는 요청을 http://www.google.com 로 redirect 할 때

RewriteCond %{HTTP_HOST} ^tmax1.tmax.co.kr$   // 앞에 ^ 뒤에 $ 는 정확한 매칭이 필요할 경우 넣는다. 빼면 이외에도 적용

RewriteRule . http://www.google.com [L] 

2. tmax1.tmax.co.kr:26000/ 으로 들어오는 모든 요청에 대해 tmax1.tmax.co.kr:26000/session/index.jsp로 redirect 할 때

RewriteCond %{HTTP_HOST} ^tmax1.tmax.co.kr:26000$

RewriteRule ^/$ /session/index.jsp [R,L] 

3. tmax1.tmax.co.kr:26000/session/ 요청에 대해 http://www.google.com 로 redirect 할 때

RewriteCond %{HTTP_HOST} ^tmax1.tmax.co.kr

RewriteCond %{SERVER_PORT} 26000$

RewriteCond %{REQUEST_URI} ^/session/$

RewriteRule . http://www.google.com [L]

4. tmax1.tmax.co.kr:26000/session/ 요청에 대해 tmax1.tmax.co.kr:26000/session/index.jsp 로 redirect 할 때

RewriteCond %{HTTP_HOST} tmax1.tmax.co.kr:26000$

RewriteCond %{REQUEST_URI} ^/session/$

RewriteRule . http://tmax1.tmax.co.kr:26000/session/index.jsp [R,L]

https://waspro.tistory.com/198

https://www.google.com/search?q=400+bad+request+ssl&tbm=isch&ved=2ahUKEwiluMOk0a_vAhVI_5QKHaudDnAQ2-cCegQIABAA&oq=400+bad+request+ssl&gs_lcp=CgNpbWcQAzIECAAQGDIECAAQGDoCCAA6BAgAEB5QmjFYpjVg2DZoAHAAeACAAXeIAdUDkgEDMC40mAEAoAEBqgELZ3dzLXdpei1pbWfAAQE&sclient=img&ei=de1NYOWpCcj-0wSru7qABw&bih=907&biw=1680&rlz=1C1CHBD_koKR937KR937#imgrc=AxcmMLvrOzmk9M

https://gmate.tistory.com/317

번외로 ssl https = http 충돌 관련 처리 방법 설정 FIX