2010-06-25 8 views
0

간단한 301 규칙을 codeigniter 사이트의 .htaccess 파일에 추가하려고합니다. 내가 http://sub.domain.com/newsletter를 방문 할 때htaccess 301 리디렉션이 작동하지 않습니다.

redirect 301 /newsletter http://sub.domain.com/newsletters/may2010 

리디렉션 내가?/뉴스 레터는 어디에서 오는 확실하지 않다

http://sub.domain.com/newsletters/may2010/?/newsletter 

에 간다. 전체 .htaccess 파일 :

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/ 

    redirect 301 /newsletter http://sub.domain.com/newsletters/may2010 

    #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] 

    #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> 

##################################################### 
# CONFIGURE media caching 
# 
Header unset ETag 
FileETag None 
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$"> 
Header unset Last-Modified 
Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT" 
Header set Cache-Control "public, no-transform" 
</FilesMatch> 
# 
##################################################### 

<IfModule mod_deflate.c> 
<FilesMatch "\.(js|css)$"> 
SetOutputFilter DEFLATE 
</FilesMatch> 
</IfModule> 

어떻게 해결할 수 있습니까?

답변

0

어, 아파치가 부적절한 주문 처리 방법을 사용하고 있습니다. 결과적으로 파일 상단에 Rewrite 명령을 넣었다 고해서 실제로 실제로 먼저 실행되는 것은 아닙니다. 대신에 mod_rewrite이 먼저 실행되고 mod_alias (Rewrite을 처리해야 함)이 실행됩니다.

이 다음 변환 결과, mod_rewrite 당 :

newsletter --> index.php?/newsletter 

mod_rewrite 행복하게 ?/newsletter에 쿼리 문자열을 설정하지만 사용자가 지정한 PT 플래그를 가지고 있지 않기 때문에,하지 하지은 다시 URL을 통과 index.php ~ mod_alias. 따라서 mod_alias은 여전히 ​​/newsleter 경로를보고 http://sub.domain.com/newsletters/may2010으로 리디렉션하고 거래 문자열을 봉쇄하기 위해 (지금 변경된) 쿼리 문자열 ?/newsletter을 끝에 추가합니다. 재미있는 것들, 맞죠?

#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 
RewriteCond %{REQUEST_URI} !newsletter$ 
RewriteRule ^(.*)$ index.php?/$1 [L] 
:

어쨌든,이 시나리오에 대한 빠른 수정은 newsletter에 대한 요청을 무시하는 것

관련 문제