[codeigniter] Codeigniter-지정된 입력 파일 없음

저는 Codeigniter의 초보자이고 CI 튜토리얼을보고 간단한 작업을하려고했습니다. CI를 다운로드하고이 파일을 컨트롤러 디렉터리에 추가했지만 작동하지 않습니다.

<?php

class site extends CI_Controller
{
    public function index()
    {
        echo "Hello World";
    }

    function dosomething()
    {
        echo "Do Something";
    }
}
?>

http : //…./index.php/site를 사용하여 액세스하려고 하면 출력이 표시됩니다 … “지정된 입력 파일 없음”…. 그런데 파일 이름을 site.php로 지정했습니다.



답변

그냥 ? .htaccess 파일에서 index.php 뒤에 서명하십시오.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

그리고 그것은 작동 할 것입니다!


답변

GoDaddy이은에 고정 된 것 같다 호스팅 .htaccess자신이 노력하고,

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

…에

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


답변

여기에서이 질문에 대한 답을 찾았습니다 ….. 문제는 호스팅 서버였습니다 … 시도해 주신 모든 분들께 감사드립니다. …. 이것이 다른 사람들에게 도움이되기를 바랍니다.

Godaddy 설치 팁


답변

CodeIgniter 앱의 .htaccess 파일에있는 RewriteEngine, DirectoryIndex

방금 .htaccess 파일 내용을 변경했으며 다음 링크에 표시된대로 대답했습니다. 그리고 페이지를 새로 고치려고 시도했습니다 (작동하지 않았고 컨트롤러에 대한 요청을 찾을 수 없음).

그런 다음 의심 때문에 public_html 폴더 내의 .htaccess에 대한 변경 사항 을 원래 .htaccess 콘텐츠로 되돌 렸습니다 . 이제 다음과 같습니다 (원래 그대로입니다).

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

그리고 지금도 작동합니다.

힌트 : 재 작성 규칙이 서버 컨텍스트 내에서 명확하게 설정되지 않은 이전과 같습니다.

내 파일 구조는 다음과 같습니다.

/
|- gheapp
|    |- application
|    L- system
|
|- public_html
|    |- .htaccess
|    L- index.php

그리고 index.php시스템과 응용 프로그램에 대한 다음 경로를 설정했습니다.

$system_path = '../gheapp/system';
$application_folder = '../gheapp/application';

참고 : 이렇게하면 처음에는 애플리케이션 소스 코드가 공개되지 않습니다.

제 대답에 잘못된 점이 있으면 댓글을 달고 다시 수정하십시오!
초보자가이 답변이 도움이되기를 바랍니다.

감사!


답변

내 사이트는 MochaHost에 호스팅되어 있습니다. .htaccess 파일을 설정하여 내 URL에서 index.php를 제거 할 수 있습니다. 그러나 인터넷 검색 후이 스레드에 대한 답변과 다른 답변을 결합했습니다. 내 최종 작업 .htaccess 파일에는 다음 내용이 있습니다.

<IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On

    # If your website begins from a folder e.g localhost/my_project then 
    # you have to change it to: RewriteBase /my_project/
    # If your site begins from the root e.g. example.local/ then
    # let it as it is
    RewriteBase /

    # Protect application and system files from being viewed when the index.php is missing
    RewriteCond $1 ^(application|system|private|logs)

    # Rewrite to index.php/access_denied/URL
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

    # Allow these directories and files to be displayed directly:
    RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|app_upload|assets|css|js|images)

    # No rewriting
    RewriteRule ^(.*)$ - [PT,L]

    # Rewrite to index.php/URL
    RewriteRule ^(.*)$ index.php?/$1 [PT,L]
</IfModule>


답변