2011-04-21 10 views
0

아파치와 Zend Comunity Server를 사용하는 Windows 컴퓨터에서 CodeIgniter를 사용하고 있습니다. 내 아파치가 제대로 htaccess로 지시문을 처리하도록 구성되어 mod_rewrite를은 (을 httpd.conf) 사용할 수 있습니다 :CodeIgniter remove index.php apache mod_rewrite

<Directory /> 
    Options FollowSymLinks 
    AllowOverride FileInfo 
    Order deny,allow 
    Deny from all 
</Directory> 

내 뿌리는 C:\www\하고 내 사이트는 C:\www\david\에 위치하고 있으며 내가 http://localhost/david/를 입력 할 때의 index.php는로드입니다 올바른 컨트롤러와 함께 http://localhost/david/index.php/Articles/ 대신 http://localhost/david/Articles/을 통해 직접 내 물건에 액세스하고 싶습니다. 이렇게하려면 아파치 재 작성 모듈을 사용해야합니다.

이렇게하려면 C:\www\david\ 폴더에 .htaccess 파일을 넣었습니다. 내 구성은 기본에서 약간 다르기 때문에 내가 코드 변경의 몇 가지를 만들어

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /david/ 

    #Removes access to the system folder by users. 
    #Additionally this will allow you to create a System.php controller, 
    #previously this would not have been possible. 
    #'system' can be replaced if you have renamed your system folder. 
    RewriteCond %{REQUEST_URI} ^core.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    #When your application folder isn't in the system folder 
    #This snippet prevents user access to the application folder 
    #Submitted by: Fabdrol 
    #Rename 'application' to your applications folder name. 
    RewriteCond %{REQUEST_URI} ^application.* 
    RewriteRule ^(.*)$ /index.php?/$1 [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 index.php 
    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> 

:이 파일은 내가 here에서 발견 코드가 포함되어 있습니다. 나는 루트에 있지 않으므로 : 'RewriteBase/davidfrancoeur.com/'및 CodeIgniter 시스템 폴더의 이름을 바꿔 보안을 강화했습니다. RewriteCond % {REQUEST_URI}^핵심. * RewriteRule^(. *) $/index.php?/$ 1 [L]

이 작업을 수행하면 아무 문제없이 올바르게 작동해야하는데 http://localhost/david/Articles/에 문제없이 액세스 할 수 있어야하고 http://localhost/david/core/config/config.php에 직접 연결할 수 없어야한다고 생각합니다.

불행히도, 그것은 작동하지 않습니다, 어떤 재 작성이 완료된 것처럼 보이지 않습니다. 내가 여기서 뭔가 잘못하고있는 걸 보니? 아파치가 실제로 어떤 것을 다시 작성하는지 알 수있는 방법이 있습니까?

고마워요. 그리고 예 나는 ... :(2.0.2

편집

CI, PHP 5.3, 아파치 2.2

답변

1

제 젠드 커뮤니티 서버의 httpd.conf를주의 깊게 살펴본 후 <Directory /> 명령어가 두 개 있다는 것을 깨달았습니다.

<Directory "C:\Dropbox\www"> 
    # 
    # 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.2/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. 
    # 
    Order allow,deny 
    Allow from all 
</Directory> 

내가에 AllowOverride All`에 다음 줄 AllowOverride None을 변경하고 일 : 질문에 표시하고, 두 번째는 그 모습으로 첫 번째는 비어 있었다. http://codeigniter.com/wiki/mod_rewrite/

을 그리고 AllowOverride 읽고 무엇을 제대로 이해하기 : http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride

감사를 다시 적 도움에 CodeIgniter를이 모양으로 URL 재 작성에 대한 자세한 내용을 알고 싶은 사람들을 위해!

3

그것은 작동 내가 이것에 대해 찾을 수있는 문서의 수백만 보았다 ... ..actually 처음이 재 개 작성 조건과 규칙이 작동되지만 세 번째 재 작성 상태는 사용자가 요청 파일에 액세스 할 수 있도록하는, 그것은 코어 또는 시스템 파일 인 경우에도

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

편집 :. 고정 '재 작성'

을 오타
+0

여전히 코어 폴더 앱 SYS 폴더에 액세스 할 가 표시됩니다. – David

0

ppet는 사용자가 응용 프로그램 폴더에 액세스하지 못하도록합니다. # 제출자 : Fabdrol # 응용 프로그램 폴더 이름에 'application'을 씁니다. 한다 RewriteCond % {REQUEST_URI}^애플리케이션. * RewriteRule의 (^. *) $ /index.php?/$1 [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 index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L]