2013-09-04 3 views
2

내가 실수로 작업 영역에서 모드 재 작성 규칙에 문제가 있습니다. :) 프로젝트 사이트 마녀는 아약스 반환 사이트입니다. 그래서 sitename.com/my-test/project/test.html에서 내 사이트를 열고 sitename.com/my-test/project.html?index=test로 다시 작성해야합니다. 내 재 작성 후 cms의 다시 쓰기 규칙이 자신의 작업에 적용되어야한다는 것을 알고 있습니다. Im는 아마 이것이 문제 다라고 확신하지 않는다. 그리고 그들은 교차하거나 부서진다.아파치 mod_rewrite - 다시 쓰기 규칙

브라우저를 통해 URL을 탐색하면 모두 정상적으로 작동하며 다시 쓰기 규칙 만 작동하지 않아 완전히 열세가되어 문제를 찾을 수 없습니다.

누군가가 나를 도울 수 있기를 바랍니다. 모든

감사

REWRITE htaccess로

RewriteEngine On 
    RewriteBase/

    #### WOULD NOT WORK ###### 
    # REWRITE AJAX PROJEKT 
    RewriteCond %{REQUEST_URI}% ^my-test/projects/[a-zA-Z0-9]+\.html$ [NC] 
    RewriteRule ^my-test/projects/[a-zA-Z0-9]+\.html my-test/projects.html?index=$1 

    ### WORK CORRECTLY #### 
    # REWRITE RULE FOR SEO FRIENDLY IMAGE MANAGER URLS 
    RewriteRule ^files[0-9]*/imagetypes/([^/]*)/([^/]*) index.php?rex_img_type=$1&rex_img_file=$2 

    # DON'T REWRITE IF REAL FILE, FOLDER OR SYMLINK EXISTS 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-l 

    # EXCLUDE SPECIFIC FOLDERS FROM REWRITE ENGINE 
    RewriteCond %{REQUEST_URI} !/files[0-9]*/ 
    RewriteCond %{REQUEST_URI} !/assets/.* 
    RewriteCond %{REQUEST_URI} !/media/.* 
    RewriteCond %{REQUEST_URI} !/redaxo/.* 

    # REWRITE ALL OTHER REQUESTS TO INDEX.PHP 
    RewriteRule ^(.*)$ index.php?%{QUERY_STRING} [L] 

에서 Config 나는 또한

RewriteCond %{REQUEST_URI}% ^/my-test/projects/[a-zA-Z0-9]+\.html$ [NC] 
    RewriteRule ^/my-test/projects/[a-zA-Z0-9]+\.html my-test/projects.html?index=$1 
    #OR JUST 
    RewriteRule ^/my-test/projects/[a-zA-Z0-9]+\.html$ my-test/projects.html?index=$1 
    #OR 
    RewriteRule ^/my-test/projects/(.*)$ my-test/projects.html?index=$1 
    #AND CORRECT 
    RewriteCond %{REQUEST_URI} ^/my-test/projects/[a-zA-Z0-9]+\.html$ [NC] 
    RewriteRule ^/my-test/projects/[a-zA-Z0-9]+\.html my-test/projects.html?index=$1 
    #AND --- 
    RewriteRule ^my-test/projects/([a-zA-Z0-9]+)\.html my-test/projects.html?index=$1 [L] 

내가 답을 찾을 해달라고을 테스트 한, 그래서 내가 정말 누군가가 나에게

을 도울 수 있기를 바랍니다

ng moxx ​​

답변

0
RewriteCond %{REQUEST_URI}% ^my-test/projects/[a-zA-Z0-9]+\.html$ [NC] 
RewriteRule ^my-test/projects/[a-zA-Z0-9]+\.html my-test/projects.html?index=$1 

귀하의 상태가 끝나면 %이 추가로 있습니다 : %{REQUEST_URI}%. 즉, 요청 URI 뒤에 %이 있어야하며, 오른쪽 텍스트는 html으로 끝납니다. 즉,이 조건은 항상 실패합니다.

또한 %{REQUEST_URI} 변수 /으로 시작합니다. 재 작성 규칙의 패턴과 일치시킬 때 선행 슬래시는 사용되지 않습니다.

실제로 조건이 전혀 필요하지 않습니다.

RewriteRule ^my-test/projects/([a-zA-Z0-9]+)\.html my-test/projects.html?index=$1 [L] 
+0

안녕하세요, 빠른 재생을위한 thx입니다. 픽스는 작동하지 않습니다. ( – moxx

+0

@ user1807046 답변 끝에서 규칙을 다시보십시오. 캡처 그룹 (괄호)이 누락되었습니다 –

+0

thx도 작동하지 않습니다. (((RedirectMatch 만 작동합니다. > RedirectMatch ^/my-test/projects/([a-zA-Z0-9] +) \ .html http://sitename.com/my-test/projects.html?index=$1 – moxx