2009-06-25 3 views
0

그래서 더 예뻐 뭔가 내 추한 PHP는 URL을 다시 작성했다 : mod_rewrite를 가진 prettified URL을 강제

http://www.example.com/main/details.php?gid=20&pid=5 

로 리디렉션

RewriteEngine On 
RewriteRule ^main/photo([^/\.]+)/?.html$ main/details.php?gid=$2pid=$1 

그러나, 지금은

가는 사람을 강제 할
htto://www.example.com/main/photo5.html 

다음 재 작성 시도 :

RewriteCond %{REQUEST_URI} ^/main/details\.php [NC] 
RewriteRule ^main/details.php?gid=(.*)&pid=(.*) http://www.example.com/main/photo$1.html [R=301,L] 

하지만 작동하지 않았습니다. 어떤 아이디어?

답변

0

현재 요청 URI가 원본인지 확인하려면 request line을 조사해야합니다. 또한 RewriteCond 지시문을 사용하여 URI 쿼리를 테스트해야합니다.

RewriteCond %{THE_REQUEST} ^GET\ /main/details\.php 
RewriteCond %{QUERY_STRING} ^(([^&]*&)*)pid=([0-9]+)(&.*)?$ 
RewriteRule ^main/details\.php$ /main/photo%3.html? [L,R=301] 
+0

나는 photo.html? pid = 5로 보내집니다. –

+0

@Lenni : 작성했습니다. – Gumbo

+0

이제 photogid = 73 & .html로 리디렉션됩니다. 어느 부분이 % 1에 의해 캡처 된 것을 결정합니까? –

관련 문제