방법

2015-01-29 12 views
0

내 htaccess로 코드방법

RewriteCond %{THE_REQUEST} \s/detail\.php\?id=([_0-9a-zA-Z-]+)\s [NC] 
RewriteRule ^temp/detail/%1? [R=301,L] 
RewriteRule ^temp/detail/([_0-9a-zA-Z-]+)$ /detail.php?id=$1 [L] 

temp.example.com/detail.php?id=xxxxxx 

에서

temp.example.com/detail/xxxxxx 

처럼 내 URL을 파일 형식을 초래하지 않고 URL의 끝에 .html 중에서 넣어 지금은 원하는 끝에 .html을 추가하면 URL은 다음과 같이됩니다.

temp.example.com/detail/xxxxxx.html 

나는 위와 같이 내 URL을 만들 것입니다 및 htaccass 규칙을 필요로하지만, HTML처럼 행동해서는 안된다.

감사

+0

이 왜 전혀 확장 필요합니까? 그것은 SEO 친절하지 않습니다. – Daan

+0

같은 질문을했지만, 보스는 항상 당신이 알고있는 바로 : P –

+1

그것은 stackoverflow에 여러 번 요청되었습니다. [답변 1] (http://stackoverflow.com/questions/5745490/rewrite-rule-to-add-html-extension) [답변 2] (http://stackoverflow.com/questions/18682420/htaccess-add-html- urls-with-without-without-trailing-slash)를 사용하여 웹 사이트를 확장 할 수 있습니다. 그런 다음 상황에 맞는 규칙을 조정하면됩니다. – Kev

답변

0

사용이 루트 .htaccess :

RewriteCond %{THE_REQUEST} \s/detail\.php\?id=([_0-9a-zA-Z-]+)\s [NC] 
RewriteRule^detail/%1.html? [R=301,L] 
RewriteRule ^detail/([_0-9a-zA-Z-]+?)(?:\.html)?$ detail.php?id=$1 [NC,L]