2014-03-04 1 views
0

로컬로 개발하기 위해 wamp를 사용하여 (Apache 2.4) codeIgniter에서 프로젝트를 만들고 있습니다. 프로젝트 전체에서 나는 mod_rewrite를 켜서 codeigniter 프로젝트 디렉토리에있는 .htaccess 파일 (즉 C:\wamp\www\codeIgniter\.htaccess)을 사용하여 기본적으로 codeigniter의 URL에 나타나는 index.php을 제거했습니다. 서버 설정에서 sspi 규칙을 적용한 후에 mod_rewrite가 더 이상 적용되지 않습니다.

우리는 마침내 LDAP 및 작업 sspi 모듈을 얻을 관리 후 수 있도록 응용 프로그램에서 Windows 인증이 필요, 나는이 설정 here있어 c:wamp\bin\apache\Apache2.4.4\conf\httpd.conf

<Directory "c:/wamp/www/codeIgniter"> 
AllowOverride None 
Options None 
Order allow,deny 
Allow from all 

AuthName "protected" 
AuthType SSPI 
SSPIAuth On 
SSPIAuthoritative On 
SSPIOmitDomain On 

require valid-user 
</Directory> 

의 httpd.conf 파일에 다음을 적용했다.

httpd.conf 파일을 변경 한 후 mod_rewrite 규칙이 더 이상 적용되지 않는 것으로 보입니다.로드 할 URL을 얻으려면 프로젝트 루트 뒤에 index.php을 써야합니다.

In general, you should only use .htaccess files when you don't have access to the main server configuration file. There is, for example, a common misconception that user authentication should always be done in .htaccess files, and, in more recent years, another misconception that mod_rewrite directives must go in .htaccess files. This is simply not the case. You can put user authentication configurations in the main server configuration, and this is, in fact, the preferred way to do things. Likewise, mod_rewrite directives work better, in many respects, in the main server configuration. Link

을 그래서 먼저 난 :

httpd.conf 설정하고 .htaccess 파일은 서버 설정에 액세스가 가능하면 사용하지 않아야하는 것이 좋습니다 .htaccess 파일을 설정하는 아파치 문서의 일부를 읽은 후 내 mod_rewrite 규칙을 내 sspi 항목과 함께 다시 행복하게 처리 할 수있는 방법과 두 번째로 내 mod_rewrite 규칙을 .htaccess에서 내 서버 config 파일 httpd.conf으로 옮길 수있는 방법을 이해하려고합니다.

나는 위에서 언급 한 코드 에서처럼 서버 구성에서 AllowOverride All을 전환하려고 시도했지만 이것이 모든 것을 액세스 할 수 없게 만드는 것 같습니다. 나는 또한 Order allow,denyAllow from allRequire all granted으로 변경하려고 시도했지만 비슷한 문제가있는 것으로 보입니다. mod_rewrite 규칙을 서버 설정에 추가하면 모든 것을 액세스 할 수 없게됩니다. 어떤 지침이라도 대단히 감사 할 것입니다! 고맙습니다. 다음과 같이

.htaccess은 다음과 같습니다

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /codeIgniter 
#RewriteBase /codeIgniter 

#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} ^system.* 
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 acces 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 !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 

답변

1

방법 AllowOverride 작품 읽기 최대. None.htaccess 개의 파일을 비활성화합니다. 최소한 FileInfo이 필요합니다.

액세스 파일이 각 요청을 읽고 구문 분석되기 때문에 Htaccess 파일 처리에는 성능이 저하되지만 Apache 시작시 서버 및 가상 호스트 규칙은 읽고 캐시됩니다. 그러나 이는 요청 별 규칙 기반으로 규칙 처리를 변경할 수있는 융통성을 상쇄해야합니다. 지역 개발을 위해이 조언을 무시할 수 있습니다.

다시 쓰기 규칙의 디렉토리 별 처리 차이점에 대해서도 읽습니다. 특히 모든 RewriteRule 일치 패턴에 선행 /자를 놓습니다. 반대로 요청 URI에는 항상 /이라는 내용이 포함됩니다.

RewriteCond %{REQUEST_URI} ^/system/ 
RewriteRule ^(.*)$ index.php?/$1 [L] 

나는 이것이 당신이하려는 것을 확신하지는 않지만 의미가 있습니다. 당신의 두 가지 규칙을하는

포스트 스크립트

더 우아한 방법은 예를 들어, 그들을 결합하는 것입니다

RewriteCond %{REQUEST_URI} ^/(system|application)/ 
RewriteRule ^.* index.php?/$0 [L] 
+0

답장과 링크에 감사드립니다. 'AllowOverride None'을'AllowOverride FileInfo' 나'AllowOverride All'로 바꾸거나 주석으로 처리한다면,'와 같이 이전 지시어를 취하는 것으로 가정합니다.'Allow from all '다음 403 오류가 발생합니다 : ** 금지됨이 서버에서/codeIgniter /에 액세스 할 수있는 권한이 없습니다. **이 오류 페이지가 나타나는 이유를 이해할 수 없습니다. AllowOverride All' 또는'FileInfo' .htaccess가 금지 된 오류를 발생시키지 않는다고 가정하는 재 작성 작업을 수행하도록 허용하고 있습니다. – haakym

+0

내가 이전에 언급 한 " c :/wamp/www">와 같이 이전 지시문을 사용한다고 가정 할 때 "AllowOverride All"이 있습니다. – haakym

0

나는 대답 here에 주어진 조언을 따라이 문제를 해결하는 것 같았다. 그래서 나는이 문제가 옵션 지시자를 바꾸는 것으로 추측했다. 지금과 같이 변경된 내 httpd.conf 파일의

부분은 :

<Directory /> 
#AllowOverride none 
#Require all granted 

#Options FollowSymLinks 
Options Indexes FollowSymLinks Includes ExecCGI 
AllowOverride All 
Order deny,allow 
Allow from all 
</Directory> 

<Directory "c:/wamp/www/codeIgniter"> 
#AllowOverride FileInfo AuthConfig 
#Options None 
Order allow,deny 
Allow from all 

AuthName "protected" 
AuthType SSPI 
SSPIAuth On 
SSPIAuthoritative On 
SSPIOmitDomain On 

require valid-user 
</Directory> 

는 내가 재 작성 규칙 내 .htaccess 파일에 너무 좋습니다 @TerryE 변경했다. 그들은 이제 다음과 같이 보입니다 :

RewriteCond %{REQUEST_URI} ^/system/ 
RewriteRule ^(.*)$ index.php?/$1 [L] 

RewriteCond %{REQUEST_URI} ^/application/ 
RewriteRule ^(.*)$ index.php?/$1 [L] 
+1

내가 말한대로 AllowOverride와 Options에서 문서를 읽으십시오. 사용자가 codeIgniter 폴더의 디렉토리 목록을 실제로 열도록 허용 하시겠습니까? AllowOverride FileInfo AuthConfig와 Options FollowSymLinks 이외의 것이 필요한 이유가 무엇인지 모르겠습니다. – TerryE