2015-01-11 4 views
1

.htaccess 파일에 문제가 있습니다. 내 인덱스 페이지를 웹 서버에 호스팅했습니다. 나는 여기에.htaccess 파일에 문제가 있습니다.

<html> 
    <head> 
     <title>Second mod_rewrite example</title> 
    </head> 
    <body> 
     <p> 
      welcome index page. Index page is loaded 
      <a href="http://rang.comli.com/servicecnt.php?service_id=5">Done with php my admin</a> 
     </p> 
    </body> 
</html> 

http://rang.comli.com/servicecnt/service_id/5 내 htaccess로 파일입니다 그것은해야 난 아직도 내 URL이 friendly.It가 http://rang.comli.com/servicecnt을 보여주는되지 htaccess로 파일에 코드를 추가 htaccess로의 file.After에서 뭘 잘못했는지 모르겠어요 :

Options +FollowSymLinks -MultiViews 

# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

## hide .php extension 
# To externally redirect /public_html/index.php to /dir/index 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule^%1 [R,L,NC] 

## To internally redirect /public_html/index to /dir/index.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule^%{REQUEST_URI}.php [L] 
RewriteEngine On 
RewriteCond %{QUERY_STRING} ^service_id=([0-9]*)$ 
RewriteRule ^servicecnt\.php$ /servicecnt.php/%1? [R=302,L] 
+0

중 하나가 나를 도울 수 htaccess로는 –

+0

어느 한 날 hepl 수 성가신? –

+0

인내심은 좋은 것입니다. 그것을 습득하는 방법을 배우십시오. – Sumurai8

답변

0

당신은 사용할 수 있습니다

Options +FollowSymLinks -MultiViews 

# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} \s/+servicecnt\.php\?service_id=([^\s&]+) [NC] 
RewriteRule^servicecnt/service_id/%1? [R=302,L] 

## hide .php extension 
# To externally redirect /public_html/index.php to /dir/index 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] 
RewriteRule^%1 [R,L] 

RewriteRule ^servicecnt/service_id/(\d+)/?$ servicecnt.php?service_id=$1 [QSA,L] 

## To internally redirect /public_html/index to /dir/index.php 
RewriteCond %{REQUEST_FILENAME}.php -f 
RewriteRule^%{REQUEST_URI}.php [L] 
+0

나는 당신이 어떻게 RewriteCond % {THE_REQUEST} \ s/+ servicecnt \ .php \? service_id = ([^ \ s &] +) [NC]를 작성했다고 생각하는지 알고 싶다. RewriteRule^servicecnt/service_id /%1? [R = 302, L]. 나 한테 설명 할 수 있니? 이 줄? –

+0

테스트에 효과가 있습니까? '% {THE_REQUEST} '변수를 사용했습니다. 'THE_REQUEST' 변수는 브라우저에서 Apache가받은 원래 요청을 나타내며 일부 다시 쓰기 규칙을 실행 한 후에 덮어 쓰지 않습니다. 이 변수의 예제 값은'GET /index.php?id=123 HTTP/1.1'입니다. – anubhava

+0

네, PHP 관리자와 완료를 클릭하면 http://rang.comli.com/ 링크를 볼 수 있습니다. \ s 의미는 무엇입니까? sercicecnt.php? service_id 또는 query string 또는 apache와 관련이 있습니까? –

0

당신의 최선의 선택은 이전 URL을 리디렉션하지만 PHP는 처음에 꽤 URL을 생성 할 수 있도록하지 않습니다. 사용자가 링크를 클릭 할 때마다 서버가 사용자를 리디렉션해야하므로 매우 비효율적입니다. 대신 사용자가 새 URL을 클릭하면 내부적으로 다시 작성하면됩니다. 당신은 그것을 다시 재 작성하기 위해 다음과 같은 규칙을 사용할 수 있습니다

RewriteRule ^servicecnt/service_id/([^/]+)/?$ servicecnt.php?service_id=$1 [L] 
관련 문제