CI 묻고 답하기

제목 우분투 18.01 index 죽이기 문의
카테고리 CI 2, 3
글쓴이 봉이김선달 작성시각 2019/10/18 11:02:31
댓글 : 5 추천 : 0 스크랩 : 0 조회수 : 15377   RSS

안녕하세요 index 죽이기를 시도해보고 안되서 고수님의 조언을 요청드립니다.

우분투 18.04 기준이며, 18.04에는 httpd.conf가 없는점에서 기존 16.04와 다를 수 있습니다.

CI파일들은 기본경로인 /var/www/html/ 밑에 있습니다.

설정은 아래와 같으며, 이경우 index.php 죽이기가 안됩니다. 사이에 index.php를 넣었을 경우는 잘 노출됩니다.

예)  abc.com/index.php/auth/login (O)      abc.com/auth/login (X)

고수님들의 답변을 기다리겠습니다.

 

1) mod_rewrite

- phpinfo에서 Loaded Modules 에 mod_rewirte 설치확인.

 

2) .haccess ( /var/www/html/ )

<IfModule mod_rewrite.c> 

     RewriteEngine onRewriteCond $1 !^(index\.php|db|uploads|favicon\.ico)RewriteRule ^(.*)$ ./index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>   

    ErrorDocument 404 /

</IfModule>

 

3) apache2.conf ( /etc/apache2/ )

<Directory />

   Options FollowSymLinks

   AllowOverride All

</Directory>

<Directory /usr/share>

   AllowOverride None

   Require all granted

</Directory>

<Directory /var/www>

    Options Indexes FollowSymLinks

    AllowOverride All

   Require all granted

</Directory>

 

4) 000-default.conf ( /etc/apache2/sites-available/ )

<VirtualHost *:80>

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

 <Directory />

   Options FollowSymLinks

   AllowOverride All

</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

 

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


첨부파일 info.png (56.4 KB)
 다음글 centos7 / ci 3 / php 5.6 sessi... (9)
 이전글 헤더 알림 기능 구현 질문드려요 (6)

댓글

kaido / 2019/10/18 11:33:43 / 추천 0

저는 도커로 18.04 ubuntu:bionic 버전으로 여러번 설치 해보았습니다.

도커라서 약간 다를수 있긴한데, 우분투 apache2 버전이 사실 conf 파일이 여러가지 입니다.

인클루드를 잘 따라가 보시면 상황별로 설정 하는 구조로 되어있을거라 짐작 됩니다.

저는 sites-enabled/000-default.conf 파일에 설정했었는데, 한번 확인해 보세요.

 

//000-default.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/public
        
        <Directory "/var/www/html/">
                #Options Indexes FollowSymLinks Includes ExecCGI
                AllowOverride All
                Require all granted
        </Directory>

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        

        
</VirtualHost>

 

변종원(웅파) / 2019/10/18 11:51:13 / 추천 0
sites-enabled 디렉토리가 맞습니다.
봉이김선달 / 2019/10/18 15:06:25 / 추천 0

sites_enabled 디렉토리 내에는 바로가기형태로 /etc/apache2/sites-available/ 을 포인팅하고 있어 실제로 sites-available 내의 000-default.conf 을 가르키고 있습니다.

Kaido님 파일과 동일하게 해봤는데 안되네요.

단, DocumentRoot 는 /var/www/html/로 지정햇습니다. public은 codeigtnier4의 기본디렉토리 같으며, 3에서는 /html/인것 같아서요...  

어떻게 해야할지... 아....

변종원(웅파) / 2019/10/18 15:11:24 / 추천 0

ci 버전은요? index.php 가 있는 곳에 ,htaccess 파일이 존재해야 합니다. 퍼미션도 보세요. 웹서버가 읽을 수 있어야 합니다.

virtualhost 구문을 타지 않고 상위 기본셋팅에서 넘어올 수도 있을 것 같네요.

봉이김선달 / 2019/10/18 15:37:41 / 추천 0

CI 3이며, .htaccess를 아래와 같이 변경하니 되네요. 파일위치는 /html/ 폴더내 입니다.

htaccess 파일에서 "."을 빼먹은건지 아니면 아래와 깉이 세팅을 안해서 그런건지 모르겠으나 해결했습니다. 참고차 .htaccess 내용 남깁니다.

<IfModule mod_rewrite.c> 
RewriteEngine On
#RewriteCond $1 !^(index\.php|images|capcha|data|include|db|uploads|favicon\.ico|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: ElliotHaughin
    ErrorDocument 404 /index.php
</IfModule>
 
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin: "*"
</IfModule>