2011-03-10 4 views
0

내가이 htaccess로htaccess로 URL 재 작성에 도움


RewriteEngine On 
RewriteBase/
RewriteCond %{HTTP_HOST} !^www\.test\.com$ [NC] 
RewriteRule ^(.*)$ http://www.test.com/$1 [R=301,L] 



RewriteRule ^home.html$ index__.php [L] 
RewriteRule ^prodotti.html$ prodotti.php [L] 
RewriteRule ^azienda.html$ azienda.php [L] 
RewriteRule ^news.html$ news.php [L] 
RewriteRule ^outlet.html$ outlet.php [L] 
RewriteRule ^contatti.html$ contatti.php [L] 

RewriteRule ^news-(.*).html$ news.php?id=$1 [L] 

RewriteRule ^arr.html$ prodotti-cat.php?cat=a [L] 
RewriteRule ^sed.html$ prodotti-cat.php?cat=s [L] 
RewriteRule ^par.html$ prodotti-cat.php?cat=p [L] 
RewriteRule ^cont.html$ prodotti-cat.php?cat=c [L] 
RewriteRule ^comp.html$ prodotti-cat.php?cat=co [L] 

RewriteRule ^outlet/([a-zA-Z0-9_-]+).html$ outlet-dett.php?prd=$1 [L] 

RewriteRule ^(.*)/(.*)/$ prodotti-cat.php?cat=$1&f=$2 [L] 
RewriteRule ^(.*)/(.*).html$ prodotti-dett.php?cat=$1&prd=$2 [L] 

이 ... 왜 ??? Help !!! 해당 파일이 존재하는 경우

+0

예를 들어 재 작성한 주소는 무엇입니까? 어떤 데이터를 얻으려고하는지 명확하게 설명하십시오. Thats –

+1

RewriteRule^outlet/([a-zA-Z0-9 _-] +). html $ outlet-dett.php? prd = $ 1 [L] – Ste

답변

0

http://www.test.it/outlet/test-2.html

http://www.test.it/outlet-dett.php?prd=test-2 

체크로 변환됩니다.

아무것도 후와 문자 ?를 포함하여 쿼리 문자열라고, 그래서 이것은 어떻게되는지입니다 :

  • 서버 부하 outlet-dett.php
  • 하고 그것을 값 test-2으로 prd라는 이름의 변수를 전달 .
  • PHP 스크립트 outlet-dett.phpprd의 값에 따라 데이터를 표시합니다.

은 당신의 재 작성 규칙의 $1다시를 참조라고합니다. RegEx의 첫 번째 괄호 사이의 일치를 참조합니다.

+0

@Ste 우리는 ** 매우 동일한 파일 **에 대해 이야기하고 있습니다. . 결과에 대한 내 대답을 편집했습니다. – vbence

+0

미안 파일을 가지고 있는데 미안하지만 오류가 발견되지 않았습니다 ... – Ste

+0

디렉토리 나'http://www.test.it/outlet-dett '에'outlet-dett.php'라는 파일이 없습니다. php? prd = test-2'는 대답을 줄 것입니다. - 세 번째 해결책은 데이터베이스에'test-2 '라는 제품이 없기 때문에 PHP 스크립트가 404 (찾을 수 없음)로 응답하는 것입니다. – vbence