2014-02-28 2 views
2

.htaccess 전문가가이 예를 보여줄 수 있습니까?.htaccess redirect : 경로를 GET 변수로 변환 하시겠습니까?

이 URL은 :

http://www.api.com/user/1 

가로 변환해야합니다

http://www.api.com/endpoint/?entity=user&id=1 

이 URL은 :

http://www.api.com/endpoint/?entity=user&id=1&action=help 
:

http://www.api.com/user/1/?action=help 

을 번역해야 하는가

당신은이 규칙 사용할 수 있습니다

답변

2

:

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)(?:/([0-9]+))?/?$ /endpoint/?entity=$1&id=$2 [L,QSA] 
+0

감사합니다! . . . . . – Geri

+0

당신을 진심으로 환영합니다. – anubhava

+0

오류, 'id'를 선택하는 방법은 무엇입니까? – Geri