2012-12-03 3 views
0

내가 주소
www.example.com/tops/test1.php?name에 주소를
www.example.com/tops/articles/first_article
리디렉션하려고 해요 리디렉션 = first_article 또한
htaccess로 디렉토리

어드레스로 어드레스를
www.example.com/tops/galleries/first_gallery
리디렉션
,174,www.example.com/tops/test2.php?name=first_gallery


www.example에
www.example.com/tops/first_page
같은 모든 다른 주소. co.kr/tops/page.php? name = first_page

다음 htaccess 파일이 나에게 리디렉션 루프를 제공합니다.

RewriteEngine on 
Options +FollowSymLinks 

RewriteRule ^/tops/articles/(.+)$ /tops/test1.php?name=$1 [L] 

RewriteRule ^/tops/galleries/(.+)$ /tops/test2.php?name=$1 [L] 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule (.*)$ ./page.php?name=$1 

Doe의 누구나 그 이유는 무엇입니까? 내가 뭘 잘못하고 있니?

미리 감사드립니다.

+0

거의 모든 것. –

+0

다음에 알 수 있도록 빠진 것이 무엇인지 알려주세요. –

+0

특히'/ tops' 패턴 –

답변

0

이 작업을 시도 할 수 있습니다 :

RewriteEngine On 
RewriteRule ^tops/articles/([a-zA-Z0-9-=_.]+)/?$ http://www.example.com/tops/test1.php?name=$1 [L] 
RewriteRule ^tops/galleries/([a-zA-Z0-9-=_.]+)/?$ http://www.example.com/tops/test2.php?name=$1 [L] 
RewriteRule ^tops/([a-zA-Z0-9-=_.]+)/?$ http://www.example.com/page.php?name=$1 [L] 

이 규칙 3 개 규칙을 교체합니다. 모든 문자에 대한

업데이트] : 그것은 /tops 디렉토리에있는 경우

RewriteEngine On 
RewriteRule ^tops/articles/([^/]*)/?$ http://www.example.com/tops/test1.php?name=$1 [L] 
RewriteRule ^tops/galleries/([^/]*)/?$ http://www.example.com/tops/test2.php?name=$1 [L] 
RewriteRule ^tops/([^/]*)/?$ http://www.example.com/tops/page.php?name=$1 [L] 

htaccess로 루트 디렉토리에 있어야합니다, 패턴 및 대체 URL에서 제거하려고합니다.

+0

의 첫 번째 하위 디렉토리에 대한 첫 번째 슬래시는 내 요구 사항에 맞지 않습니다. –

+0

귀하의 요구 사항에 따라 다릅니다! –

+0

문제는 필자가 요구하는만큼 좋은 조건을 지정하지 않았다는 것이다. 여러분이 제공 한 charecters 대신 모든 charecters를 참조해야합니다. 내가 언급 한 또 다른 점은 htaccess 파일이 http://www.example.com/tops에 있습니다. –

0

page.php은 루트 디렉토리에 존재합니까 (아니면 그 외의 /tops/ 디렉토리에 해당합니까?)?

그렇지 않으면 아마도 문제 일 수 있습니다. 마지막 규칙을 다음과 같이 변경해야합니다.

RewriteRule ^tops/(.*)$ /tops/page.php?name=$1 
+0

업데이트 된 세 번째 규칙은 완벽하게 작동합니다. 나는 그것에 아무런 문제가 없다. 문제는 첫 번째와 두 번째 규칙에 있습니다. –

+0

@Amit Aisikowitz 슬래시없이'^/tops /'대신'^ tops /'를 사용해보십시오. – jeroen

0

글쎄, 마침내 작동하게되었습니다.

나는 누구든지이 질문을 찾을 때마다 찾을 것이다.

RewriteEngine on 
Options +FollowSymLinks 

RewriteRule ^articles/(.+)$ ./test1.php?name=$1 [L] 

RewriteRule ^galleries/(.+)$ ./test2.php?name=$1 [L] 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteRule (.*)$ ./page.php?name=$1 [L] 

즐기십시오 :

여기 workd 코드입니다!