.htaccess rewrite"/책입니다.php?id=1234"를"/책/1234"
-
13-12-2019 - |
문제
이것은 내가 지금까지 내 개발 환경에서:
php_value error_log log/php.log
php_value display_errors 1
php_value magic_quotes_gpc Off
RewriteEngine On
# remove slash
RewriteCond %{REQUEST_FILENAME} !-d
# file.php to /file
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteCond %{REQUEST_URI} !^/ajax.php
RewriteRule ^(.+)\.php$ http://localhost/$1 [R=301,L]
# /file to file.php
RewriteRule ^([^/.]+)$ $1.php [L]
을 많이 봤의 개 이 규칙 그러나 나는 항상 500error:
RewriteRule ^(.*)$ /book.php?url=$1 [L]
이에 아파치 오류가 있습니다.로그:
[Fri Jul 27 19:56:51 2012] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
나는 무엇을 놓치고는,왜 리다이렉션니까?
해결책
귀하의 RewriteRule
서면으로 나타나는 것을 하려고 반대의 어떤 당신의 질문의 표제는 것입니다.당신은 말할 htaccess rewrite /book.php?id=1234 to /book/1234
, 지만,당신 RewriteRule
:
RewriteRule ^(.*)$ /book.php?url=$1 [L]
추가 쿼리 문자열을 매개 변수입니다.
The RewriteRule 아래 다시 작성합니다 rewrite /book.php?id=1234 to /book/1234
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^book\.php$ /book/%1? [L]
또한,당신이 정말로 가고 싶다면 다른 방법으로,즉다시 쓰기 /book/1234
하기 /book.php?id=1234
다음과 같이 그렇게 하도록 요청합니다.
RewriteRule ^book/(.*)$ /book.php?id=$1 [L]
다른 팁
이 작업을 시도하십시오!
# in htaccess file write this
RewriteEngine on
RewriteRule ^book/([0-9]+) book.php?id=$i
# and in you html or php file call
book.php?id=$i
.
페이지의 페이지
book/$i
.
완료됩니다.
제휴하지 않습니다 StackOverflow