2009-08-10 2 views
0

먼저 Codeigniter Framework를 사용하고 있으므로이 문제는 현재 프로세스 리디렉션과 함께 mod_rewrite를 사용하여 설정 한 해결 방법입니다..htaccess 리디렉션 오류

/index.php?/home/gclid/somestringgoeshere으로 리디렉션하려면 /?gclid=somestringgoeshere과 같은 URL을 얻으려고합니다. 그것의 다른 작업을 시도하기 전에 내가 그것을 잡으려고 오른쪽 첫번째 설정 재 작성 조건과 규칙의 위의 다음 코드를 사용하려고

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 
    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 


    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 

    RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5_$6_$7 [L] 
    RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5_$6 [L] 
    RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5 [L] 
    RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3_$4 [L] 
    RewriteRule ^([^_]+)-([^_]+)-([^.]+)$ index.php?/$1_$2_$3 [L] 
    RewriteRule ^([^_]+)-([^.]+)$ index.php?/$1_$2 [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 

    # This last condition enables access to the images and css folders, and the robots.txt file 
    # Submitted by Michael Radlmaier (mradlmaier) 

    RewriteCond $1 !^(index\.php|images|robots\.txt|css) 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

아래

내가 설정 한 현재의 .htaccess는

RewriteRule ^?gclid=(.*)$ index.php?/home/gclid/$1 [L] 

RewriteRule ^\?gclid=(.*)$ index.php?/home/gclid/$1 [L] 

RewriteRule ^/?gclid=(.*)$ index.php?/home/gclid/$1 [L] 

모두 올바른 페이지를 표시하지 않거나 500 내부 오류가 발생합니다.

답변

2

URI는의 쿼리 만 RewriteCond directive 테스트 할 수 있습니다

RewriteCond %{QUERY_STRING} ^gclid=(.*) 
RewriteRule ^$ index.php?/home/gclid/%1 [L] 

또는 일반적인 (자세한 쿼리 매개 변수를 고려할 것) :

가 가 이

아, 그런데

RewriteCond %{QUERY_STRING} ^([^&]*&)*gclid=([^&]*) 
RewriteRule ^$ index.php?/home/gclid/%2 [L] 
: RewriteCond 지시 만 해당 첫 번째는 RewriteRule입니다.

+0

필요합니까? ^^ gclid = (. *)와 같은 url에도 오류가 표시됩니다. – cointilt

+0

URI 경로는'RewriteRule' 지시문으로 만 테스트 할 수 있습니다. URI 쿼리 (첫 번째'''부터 그 이후의 첫 번째'#'까지의 부분)는'% {QUERY_STRING} '변수를 통해서만 접근 할 수 있습니다. 그리고 그것은'RewriteCond' 지시자로만 가능합니다. 그래서 제 예제가 효과가 있습니다. – Gumbo

+0

당신의 예제에서 복사 한 텍스트에 약간의 문제가 있음을 발견했습니다. 그것은 이상한 문자를 삽입했습니다. 감사! – cointilt