2012-01-06 5 views
0

저는 mod_rewrite의 초보자입니다. 클럽을위한 웹 사이트를 만들려고하고 있습니다. mod_rewrite를 사용하면 URL이 꽤 복잡해집니다. 어쨌든, 현재 개발중인 페이지이므로 하위 디렉토리에 배치했습니다. 내 페이지에 액세스하려면 mydomain.com/minisite/club/alpha를 찾으십시오.하위 디렉토리에 Mod-Rewrite

이 디렉토리 내 index.php 페이지는 페이지를 반환 할 ID를 묻습니다. 그래서 mydomain.com/minisite/club/alpha/index.php?id=1 첫 페이지를 반환합니다.

페이지를 .mydomain.com/minisite/club/alpha/page/1 /로 표시하고 싶습니다.

내가 더 잘 mod_rewrite를 이해하기 위해 읽을 수있는 유용한 문서, 마크 (index.php에가있는) 알파 폴더에서

답변

0

.../page/1 aswell 모두 검색 할 수 있습니다. 이미 규칙이있는 경우 상단에이 규칙을 추가하십시오. 여기

#if these 2 lines already exist skip them 
RewriteEngine on 
RewriteBase/

#this rule should before other RewriteCond/RewriteRules in your .htaccess 
RewriteRule ^minisite/club/alpha/page/([0-9]+) minisite/club/alpha/index.php?id=$1 [L,NC] 

은 htaccess로 몇 가지 리소스입니다 : Introduction to htaccess, htaccess Tricks는, Apache Docs on Htaccess

+0

좋아, 고마워. 이제 성가신 스타일 시트와 이미지가 작동합니다. :) –

0

, 다음 내용을 htaccess로 생성을 참조하십시오 :

RewriteEngine On 
RewriteRule ^page/(.*?)/*$ index.php?id=$1 

이것은 당신이 폴더의 루트 디렉토리에 htaccess로 파일에이 규칙을 추가 .../page/1/

+0

작동하지 않았다. 충돌하는 .htaccess 파일일까요? 위의 .htaccess 파일이 mydomain.com/에 있습니다. 'RewriteEngine on RewriteRule^([^/\.] +) .htm $ /index.php?id=$1 [L]' –

+0

아마도 이걸 옮기십시오. RewriteRule을 해당 파일에 추가하고 전체 경로를 포함하도록 수정하십시오. 예 :'RewriteRule ^/minisite/club/alpha/page /(.*?)/*$/minisite/club/alpha/index.php?id=$1 '그리고 다른 규칙들과 작동 할 때까지 그걸 가지고 놀아 라. 때로는 하나 이상의 규칙을 가지고 어질러 지기도한다. 그래서 그것을 둘러싼 다. 행운을 빕니다! –