CI 묻고 답하기

제목 index.php를 죽여야하는데, 안죽습니다...
카테고리 CI 4 관련
글쓴이 kasumil 작성시각 2021/12/23 15:18:37
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 7818   RSS

안녕하세요. 선배님들.

질문이 있어서 왔습니다.

index.php를 죽여야하는데, ci4에서는 헤매고 있습니다. 해당 글을 봤더니 적용하는데 막혔습니다...

동일하게 해도 안되서 고민이 많습니다.

현재 상황으로는 제가 Route.php.에서 $routes->get('/', 'Market::index');로 경로를 설정하고 호출까지는 정상적으로 진행됩니다.

하지만 a태그에서 href='해당 페이지.php' 클릭시 도메인.com/index.php/해당 php 접속시 정상적으로 이동하나

링크에서 index.php가 자동으로 붙지 않아서 index.php를 죽여하는데,

어떻게 죽여야 하는지 잘 모르겠습니다.

 

.htacess에서는 이렇게 유지하고 있습니다.

# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
	Options +FollowSymlinks
	RewriteEngine On

	# If you installed CodeIgniter in a subfolder, you will need to
	# change the following line to match the subfolder you need.
	# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
	# RewriteBase /

	# Redirect Trailing Slashes...
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_URI} (.+)/$
      RewriteRule ^ %1 [L,R=301]

	# Rewrite "www.example.com -> example.com"
	RewriteCond %{HTTPS} !=on
	RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
	RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

	# Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to the front controller, index.php
	RewriteBase /
	RewriteCond $1 !^(index\.php|images|captcha|data|include|uploads|robots\.txt)
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

	# Ensure Authorization header is passed along
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</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.
    ErrorDocument 404 index.php
</IfModule>

# Disable server signature start
    ServerSignature Off
# Disable server signature end

 

찾아보니 Config에서 config.php를 수정하라고 하는데, ci4에선 app/Config/config.php가 없는데 어떻게 해야 할까요?

 

 다음글 서드파티에 대해서 (2)
 이전글 이미지 경로나 css가 호출이 안되고 있습니다. (4)

댓글

kasumil / 2021/12/23 17:18:01 / 추천 0

잡았습니다.

ubuntu /etc/apache2/apache2.conf만 수정하면 됩니다.

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>

이렇게 설정하고 컨트롤러/app.php에서  public indexPage= '';로 수정하면 되는거군요 

그리고 아파치 리스타트.

ci4기준으로 해결했습니다.

프레드윤 / 2021/12/29 04:39:18 / 추천 0

이제야 봤는데 라우터에 index.php 때문에 고생하셨군요.. 

저도 초반엔 엄청 애먹었는데.. 어쨋든 유투브나 유데미 강의 보면 도움 되더라구요