나는 apache mod_rewrite
을 사용하며 지난 6 개월 동안 아무런 오류없이 작동하는 사이트가 있습니다.아파치 mod_rewrite가 표현식을 매개 변수로 매핑하지 않습니다.
난 다음 다시 쓰기 규칙이 있습니다 여기에
RewriteRule ^products/([a-z\-]+)/$ /products.php?category=$1 [NC,L]
이
products.php
$category = $_GET['category'];
if (isset($category)) {
// do some processing here
}
else {
header("Location: /500.html");
exit;
}
이 규칙을 명중 링크의 예는
사람을합니까 /products/lighting-poles/
([a-z\-]+)
을
category=$1
에 매핑하지 않는 이유를 확인하십시오.
내가 호스트의 .htaccess
파일에 Options +FollowSymLinks
그래서 내가 먼저 시도 라인을 주석 처리 한 것으로 나타났습니다
추가 정보를 원하시면 사이트가 아파치 흰색 화면을 500
오류를 반환하려면이 만 다시 할 수 있습니다. htaccess로 파일
<IfModule mod_rewrite.c>
#Options +FollowSymLinks
RewriteEngine On
RewriteBase/
# Add a trailing slash to paths without an extension
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]
# other rules including problem rule here
</IfModule>
당신이 재 작성 무엇을 의미합니까이 발생? products.php 스크립트는 여전히 호출됩니까? –
예, 400 오류가 없으며 스크립트는 여전히 products.php에서 종료됩니다. – samazi
문자 클래스에서 하이픈을 이스케이프 할 필요가 없습니다. 예를 들어'[a-z-]' – Phil