본문 바로가기

프로그래밍/PHP

php codeigniter index.php 404 not found 오류일때 수정하기

httpd.conf 파일을 vi 에디터로 열어서 보면 초중반 쯤에


<Directory />

    AllowOverride none

    Require all denied

</Directory>


이라는 내용이 나오는데 위에걸 


<Directory />

    AllowOverride All

    Require all denied

</Directory>


none -> All 로 수정해주고



또 아래로 스크롤 하다가 보면

<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

이렇게 되어있는 걸 아래처럼 


<Directory "/var/www">
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>

none -> All 로 수정해주고



마지막으로 스크롤 하고 아래로 내려가다보면

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

 똑같이 
AllowOverride None -> 부분을 AllowOverride All로 수정해주고 

컨트롤 + C
:wq 로 저장하고 종료하고

아파치를 재실행 하면 제대로 요청한 페이지가 출력된 것을 볼 수 있을 것입니다.

혹시 이렇게 했는데도 처리가 안된다면 ..htaccess 파일을 수정해야 하는데
index.php 가 있는 루트 폴더에 .htaccess 파일을 생성하고 내용은 


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteCond $1 !^(index\.php|images|captcha|data|include|uploads|robots\.txt)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

이렇게 저장하고 새로고침 하면 페이지가 뜰 것 입니다.
화이팅!