11.Nas_1


새창 작성 수정 목록 링크 Edit G카랜다 HDD HDD HDD 게시물 주소 복사


.htaccess 파일 관련 팁(웹 사이트 퍼포먼스 향상 및 트래픽 절감 효과)

♨ 카랜더 일정 :
  • 링크

  • 첨부

  • 컨텐츠 정보

    본문

    출처 : https://www.xpressengine.com/tip/22391008

    .htaccess 파일 관련 팁(웹 사이트 퍼포먼스 향상 및 트래픽 절감 효과)  2013.10.22 21:05

    서시빈목


    안녕하세요?



    가입은 아주먼옛날에 했는데 쭉 눈팅으로만있다가

    저같은 초보자분들에게 좋은정보가 있어서 쓰게되었습니다



    해당 팁은 '타이니'님께서 알려주신 정보를 동의하에 재구성하여 쓰게 되었습니다


    '타이니'님 홈피 주소 : http://kimsq.cweb.co.kr/



    자신의 웹사이트.htaccess를 수정해서 웹 사이트 퍼포먼스 향상 및 트래픽 절감 효과를 얻을수 있는 팁입니다



    - .htaccess 파일은 기본 숨김 파일이므로 ftp 프로그램에서 숨김파일 보기 옵션을 키셔야 볼 수 있고


       기본적으로 루트에 있습니다(index.php 파일 있는곳, 모듈폴더와 레이아웃폴더 들이 있는곳 있죠? 그폴더입니다)



    - 웹서버 환경설정 및 버전. 그리고 아파치모듈 설치유무에 따라 몇가지 옵션은 작동하지 않을 수 있습니다


    - 작업전에 반드시 .htaccess 파일을 백업하고 언제든지 원래 상태로 돌릴수 있는 지식을 가진 상태에서 작업해주세요


    - .htaccess파일에 한글이 입력되거나 하면 바로 오류를 뱉으니 놀라지마시고 원래상태로 돌려주시면 됩니다


    1.Database 정보파일 (./files/config/db.config.php) 보호


    자신의웹사이트주소/files/config/db.config.php 이렇게 접속해 보시면 내용은 나오지 않지만 접속이 되실겁니다


      아래 옵션을 적용하시면 해당 파일로 접근시 서버차원에서 차단시켜버립니다


        (해당 파일에는 db에 접속시 필요한 정보가 들어있습니다)



    Database 정보파일 (./files/config/db.config.php) 보호


    #Option 01

    <files db.config.php>

    order allow,deny

    deny from all

    </files>



    2. 첨부파일 폴더 (./files/attach) 보호


    이번 팁은 ./files/attach 경로에 파일명 .htaccess 로 만드신후 아래 소스를 적으시고 넣으시면됩니다


    적용 후엔 첨부파일 폴더에 악의적으로 PHP코드가 심어진 파일이 업로드 되더라도 PHP로 실행하지 않습니다


    php를 사용하지 않는다는 내용의 소스이므로 첨부파일 폴더가 아닌곳에 넣으시면 php가 작동하지 않습니다


    +


    설명이 이해가 안되시는 분들은 .htaccess 이 파일을 .htaccess라는 이름으로 ./files/attach 경로에 넣으시면됩니다


    넣기 전과 넣은 후를 테스트 해보시려면 phpver.php 이 파일을 ./files/attach 에 업로드 하고 웹에서 접속하고


    아래 팁 적용 후 다시 접속하시면 php파일이 실행되지않고 다운로드창이 뜨는걸 확인하실수 있습니다


    ?

    첨부파일 폴더 (./files/attach) 보호


    #Option 02

    <IfModule mod_php5.c>

      php_value engine off

    </IfModule>

    <IfModule mod_php4.c>

      php_value engine off

    </IfModule>



    3. .htaccess 파일 (./.htaccess) 보호


    웹 서버 유저 (호스팅사용자) 별로 일부 아파치 환경설정을 바꿀 수 있는 .htaccess 파일을 보호합니다 적용 후엔


    .htaccess 파일을 서버차원에서 보호합니다 아파치 환경설정을 변경해 악의적인 목적을 달성하는 해킹을 예방합니다


    ?

    .htaccess 파일 (./.htaccess) 보호


    #Option 03

    <files ~ "^.*\.([Hh][Tt][Aa])">

    order allow,deny

    deny from all

    </files>



    4. 웹 서버의 에러 페이지 변경


    404 Not found(파일없음),403 Forbidden(권한없음),500 Internal Server(프로그램오류) 등의 에러 발생시 원하는 페이지를


    띄울수 있습니다 적용 후 자신의웹사이트주소/가나다라 같이 없는 페이지를 입력하시면 적용된걸 보실수 있습니다


    ?

    웹 서버의 에러 페이지 변경


    #Option 04

    ErrorDocument 404 http://www.naver.com/

    ErrorDocument 403 http://www.naver.com/

    ErrorDocument 500 http://www.naver.com/



    5. 홈페이지 주소에 무조건 www 붙이기


    홈페이지 접속시 www를 붙이지 않고 접속해도 무조건 www를 붙여주는 기능입니다


    이건 애드온으로도 많이 나와있는데 개인적으로 애드온을 최소화 하는 편이라 저는 이렇게 적용시켰습니다


    ?

    홈페이지 주소에서 WWW 붙이기


    #Option 05

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteCond %{HTTPS} !=on

    RewriteCond %{HTTP_HOST} !^www\..+$ [NC]

    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    </IfModule>



    6. 이미지 파일 무단링크 방지 (jpg,jpeg,png,gif,bmp)


    자신의 서버에 있는 이미지 파일을 다른 홈페이지에서 http:// 방식으로 링크하는 것을 방지합니다


    트래픽 절약에 상당히 효과가 있지만, 홈페이지 이용회원들의 반발이 있을 수도 있으니 검토가 필요합니다


    아래 소스에 naver 라고 적힌곳에 자신의 주소를 적어주세요


    ?

    이미지 파일 무단링크 방지 (jpg,jpeg,png,gif,bmp)


    #Option 06

    <IfModule mod_rewrite.c>

    RewriteEngine on

    RewriteCond %{HTTP_REFERER} !^$

    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?www.naver.com.*$ [NC]

    RewriteRule \.(jpg|jpeg|png|gif|bmp)$ _ [NC,R,L]

    </IfModule>



    7. 데이터 파일 무단링크 방지 (pdf,zip,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)


    자신의 서버에 있는 데이터 파일을 다른 홈페이지에서 http:// 방식으로 링크하는 것을 방지합니다


    트래픽 절약에 상당히 효과가 있지만, 홈페이지 이용회원들의 반발이 있을 수도 있으니 검토가 필요합니다


    아래 소스에 naver 라고 적힌곳에 자신의 주소를 적어주세요


    ?

    데이터 파일 무단링크 방지 (pdf,zip,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)


    #Option 07

    <IfModule mod_rewrite.c>

    RewriteEngine on

    RewriteCond %{HTTP_REFERER} !^$

    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?www.naver.com.*$ [NC]

    RewriteRule \.(pdf|zip|hwp|doc|docx|ppt|pptx|pps|ppsx|xls|xlsx)$ _ [NC,R,L]

    </IfModule>



    8. 최적 CACHE 설정 - 트래픽 대폭 감소


    브라우저 캐시 관련 파일 종류별로 최적 만기일을 설정합니다 설정이 없을 경우 보통 1주일이 지나면 새로 다운로드 받습니다


    파일 종류별로 캐시 만기일을 최적 설정해 놓을 경우 약 1개월 후 부터는 웹 사이트의 재 방문율이 높을경우


    평균 트래픽이 20%이상 감소합니다


    ?

    최적 CACHE 설정 - 트래픽 대폭 감소


    #Option 08

    <IfModule mod_expires.c>

    ExpiresActive on

     

    ExpiresDefault                          "access plus 1 month"

     

    ExpiresByType text/cache-manifest       "access plus 0 seconds"

    ExpiresByType text/html                 "access plus 0 seconds"

    ExpiresByType text/xml                  "access plus 0 seconds"

    ExpiresByType application/xml           "access plus 0 seconds"

    ExpiresByType application/json          "access plus 0 seconds"

     

    ExpiresByType application/rss+xml       "access plus 3 hour"

    ExpiresByType application/atom+xml      "access plus 3 hour"

     

    ExpiresByType image/gif                 "access plus 1 month"

    ExpiresByType image/png                 "access plus 1 month"

    ExpiresByType image/jpg                 "access plus 1 month"

    ExpiresByType image/jpeg                "access plus 1 month"

       

    ExpiresByType video/ogg                 "access plus 2 month"

    ExpiresByType audio/ogg                 "access plus 2 month"

    ExpiresByType video/mp4                 "access plus 2 month"

    ExpiresByType video/webm                "access plus 2 month"

       

    ExpiresByType text/x-component          "access plus 1 year"

    ExpiresByType application/x-font-ttf    "access plus 1 year"

    ExpiresByType font/opentype             "access plus 1 year"

    ExpiresByType application/x-font-woff   "access plus 1 year"

    ExpiresByType image/svg+xml             "access plus 1 year"

    ExpiresByType application/vnd.ms-fontobject "access plus 1 year"

    ExpiresByType text/css                  "access plus 1 year"

    ExpiresByType application/javascript    "access plus 1 year"

    ExpiresByType image/x-icon              "access plus 1 year"

    </IfModule>



    9. 악성 봇 (bots) 차단


    홈페이지 전체를 통채로 긁어가는 용도의 어플이 있습니다 이와 비슷한 어플들을 악성 봇으로 판단하여 차단합니다


    이런 어플을 사용하는 사람들은 나름의 이유가 있겠습니다만, 홈페이지 운영에 있어서는 트래픽은 곧 돈입니다


    ?

    악성 봇 (bots) 차단


    #Option 09

    <IfModule mod_rewrite.c>

    RewriteEngine On 

    RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]

    RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]

    RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]

    RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]

    RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]

    RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]

    RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]

    RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]

    RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]

    RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]

    RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]

    RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]

    RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]

    RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]

    RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]

    RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]

    RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]

    RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]

    RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]

    RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]

    RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]

    RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]

    RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]

    RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]

    RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]

    RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]

    RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]

    RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]

    RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]

    RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]

    RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]

    RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]

    RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]

    RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]

    RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]

    RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]

    RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]

    RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]

    RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]

    RewriteCond %{HTTP_USER_AGENT} ^Zeus

    RewriteRule ^.* - [F,L]

    </IfModule> 


    10. 디렉토리 리스팅 방지


    웹서버의 특정 폴더에 index 파일이 없을 경우 디렉토리 전체를 리스트하지 않게 합니다.


    대부분의 서버에 이미 설정되어 있습니다 단, 외국 일부 웹호스팅 업체나 개인적으로 서버 세팅을 하셨을 경우


    설정이 미처 되어 있지 않을 수 있습니다


    ?

    디렉토리 리스팅 방지

    2

    #Option 10

    Options All -Indexes



    11. 일부 데이터 파일을 브라우저에서 바로 열리는 경우없이 무조건 다운로드


         (pdf,csv,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)


    위 파일 확장자를 가진 파일은 윈도우 설정에 따라 브라우저에서 바로 열리기도 합니다


    무조건 다운로드 되도록 하는 설정이나, 아쉽게도 일부 서버 환경에서만 적용됩니다.


    ?

    일부 데이터 파일을 브라우저에서 바로 열리는 경우없이 무조건 다운로드 (pdf,csv,hwp,doc,docx,ppt,pptx,pps,ppsx,xls,xlsx)


    #Option 11

    AddType application/octet-stream .csv

    AddType application/octet-stream .xls

    AddType application/octet-stream .xlsx

    AddType application/octet-stream .doc

    AddType application/octet-stream .docx

    AddType application/octet-stream .hwp

    AddType application/octet-stream .ppt

    AddType application/octet-stream .pptx

    AddType application/octet-stream .pps

    AddType application/octet-stream .ppsx

    AddType application/octet-stream .pdf



    12. 서버 서명 (Signature) 출력 안함


    서버 관련 에러페이지를 보면 하단에 서버 서명 (Signature) 이 출력됩니다


    그 서명안에 서버 버전 정보와 호스트명 그리고 포트번호가 나오는데 해커에 의해 악용될 수 있으니 지웁시다


    ?

    서버 서명 (Signature) 출력 안함


    #Option 12

    ServerSignature Off



    이상입니다~~ 잘 모르지만 xe에 적용시 악영향을 주는건 없어보입니다


    혹시나 있다면 댓글로 지적부탁드리구 더 좋은 팁이있다면 또 알려주세요 ^^


    ===========


    3232235521_1515215879.6398.png

    [ 추가 정보 ... 더보기) ]
    뷰PDF 1,2



    office view

    관련자료

    댓글목록

    profile_image

    shimss11q님의 댓글

    shimss11q 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 아이피 (192.♡.0.1) 작성일
    목록

    새창 작성 수정 목록 링크 Edit G카랜다 HDD HDD HDD 게시물 주소 복사




    Total 1,672 / 11 Page
    [ ssh server 안드로이드엡으로 설치후 pc에서 연결 ]

    간단 linux환경의 ssh server 연결으로 엡으로 설치 연결ssh server 안드로이드엡으로 설치후 pc에서 연결ssh server 설…

    [ Let 's Encrypt 인증서를 등록하거나 갱신 할 수 없습니다. 어떡해 ]

    Let 's Encrypt 인증서를 등록하거나 갱신 할 수 없습니다.어떡해Synology 장치에서Let 's Encrypt인증서를 생성하거나 갱…

    [ tvheadend 관리자 로그인 안될때 superuser 추가후 reset 하기 ]

    ●tvheadend 관리자 로그인 안될때 superuser 추가후 reset 하기 - 관리자 admin check 잘못 제거시 괸리자 로그인 안…

    [ ● 터미널에서 파일 작성 시간 변경이 되지 않아 우분투 ui매뉴로 서울지역설정 하기 ]

    ●터미널에서 파일 작성 시간 변경이 되지 않아 우분투 ui매뉴로 서울지역설정 하기vmware ubuntu 사용조건에 터미널에서 파일생성 시간이 …

    [ ● 파일공유) 1008일자 redpill Hei Qunhui 7.0 부트 파일 다운로드 (211008에 의해… ] 댓글 12

    ● 파일공유)1008일자 redpillHei Qunhui 7.0 부트 파일 다운로드 (211008에 의해 컴파일됨)정보 출처Black Qunhu…

    [ ● ESxi로 윈도우 pe를 vm_WIN10PE64를 VM실행 사례 설정값 ]

    ●ESxi로 윈도우 pe를 vm_WIN10PE64를 VM실행 사례 설정값- 실행 후 VMRC로 웹즈라우즈 동작이 정상적으로 가동- 참고적으로 내…

    [ ● 최근빌드up_최종재설치 Redpill 부트로더 파일)ESxi 서버에 우분투 설치 기본 설정 재설치 및 … ] 댓글 42

    추가된 랜드라이브 부팅후 접속 확인하기 명령어ethtool -i eth0ethtool -i eth1확인 합니다.접속된 ip별 확인 정보ifcon…

    [ ● 시놀로지 얼굴 인식 저는 안되네요에 대한 정보 ]

    ● 시놀로지 얼굴 인식 저는 안되네요 얼굴 인식 수행설정>사진으로 이동하고얼굴 인식 활성화를 선택하여 Photo Stations의 얼굴 인…

    [ ● Proxmox (PVE)에서 xpenology tinycore redpill dsm7.0 설치 스샷 정… ] 댓글 1

    ●Proxmox (PVE)에서 xpenology redpill dsm7.0 설치 스샷 ● Proxmox ( PVE) 기본 설치는 간단한 설치 과…

    [ ● xpenology cpu information 정상적인 정보로 수정하기 및 cpu 사용량 정보 ] 댓글 1

    ● xpenology cpu information 정상적인 정보로 수정하기 및저의 11q.kr 시놀로지 서버 cpu 사용량 입니다.https:/…

    [ ●추가 네트워크 드라이버로 사용자 지정 ESXi 설치 관리자 이미지 생성 ]

    ●추가 네트워크 드라이버로 사용자 지정 ESXi 설치 관리자 이미지 생성서버에 공식 VMware HCL에 없는 네트워크 카드가 있는 경우 ESX…

    [ ● 로컬 시놀로지서버 WebDAV Server 구성 웹브라우즈로 접속하기 ]

    ● 로컬 시놀로지서버WebDAV Server 구성 웹브라우즈로 접속하기구성1) WebDAV ServerWebDAV는 사용자가 원격 서버에 저장된…


    ♥간단_메모글♥


    최근글


    새댓글



    PHP 안에 HTML ☞ 홈페이지 화면갱신 시간은 ♨
    ▶ 2024-06-02 18:43:01

    오늘의 홈 현황


    • 현재 접속자♨ 653 명
    • 오늘 가입자※ 1 명
    • 어제 가입자※ 4 명
    • 주간 가입자※ 7 명
    • 오늘 방문자 2,027 명
    • 어제 방문자 2,099 명
    • 최대 방문자 13,042 명
    • 전체 방문자 4,355,272 명
    • 전체 게시물※ 8,613 개
    • 전체 댓글수※ 24,677 개
    • 전체 회원수 11,005 명

    QR코드


    ☞ QR코드 스캔은 kakao앱 자체 QR코드

    알림 0








    최신글↑