2012-10-31 2 views
1

"/"분리 "/ 믹스 테이프는 /"나는 얻기 위해 노력하고의 URL mydomain.com/music/downloads/mixtapes/this-title/id 내가 현재 다음이 mydomain.com/music/downloads/mixtapes/item.php?title=variable1&id=variable2다시 쓰기 규칙 I 폴더에 위치한 htaccess로 파일이

을 실행합니다 약간의 방식으로 작동하지만 ID 만 사용하고 두 변수 (../mixtapes/title/id)가 /""으로 분리되어야하며 어떤 이유로 색인 페이지가 인 "/ mixtapes /" 작동하지 않습니다. 난 곤두박질 친다! 나는 이것에 약간 새로운이고 어떤 도움든지 중대하게 평가된다! item.php 페이지로 전달 URL이 <a href="title/id">에 다시 작성 내 인덱스 페이지에 BTW

난 그냥 캔트 얻을 제대로 mixtapes/title/id

현재 htaccess로 파일이 "/ 믹스 테이프 /"에있는 형식 item.php?title=a&id=b을 실행하는 것 당신의 .htaccess에서

# turn mod_rewrite engine on 
RewriteEngine On 

# rewrite all physical existing file or folder 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d 

# allow things that are certainly necessary 
RewriteCond %{REQUEST_URI} "/css/" [OR] 
RewriteCond %{REQUEST_URI} "/images/" [OR] 
RewriteCond %{REQUEST_URI} "/images/" [OR] 
RewriteCond %{REQUEST_URI} "/javascript/" 

# rewrite rules 
RewriteRule ^mixtapes/item.php(.*) - [L] 
RewriteRule ^(.*) item.php?id=$1 [QSA] 

답변

0

주석은 실제로 상태 잘못

# turn mod_rewrite engine on 
RewriteEngine On 

# if requested URL is NOT a existing file 
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
# or if requested URL is NOT a directory 
RewriteCond %{REQUEST_FILENAME} !-d 

# CSS, images, JavaScript are files and we will never pass this point when those are requested, next rules can be skipped 

# rewrite rules 
# rewrite /mixtapes/title/id to item.php?title=title&id=id 
Rewrite ^mixtapes/([^/]+)/([0-9]+) item.php?title=$1&id=$2 [L] 

# catch all other requests and handle them (optional, default would be 404 if not a physically existing file) 
Rewrite (.*) index.php [L,QSA] 

귀하의 ID는 숫자 값이라고 가정했습니다. php에서 제목 사용에 대해 알고 있어야합니다. 직접 출력하지 말고 URL을 확인하고 잘못된 제목/ID 조합을 리디렉션 할 때 사용할 수 있습니다