这是我到目前为止在我的开发环境中所拥有的:
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]我已经尝试了这个规则的很多变体,但我总是得到一个500错误:
RewriteRule ^(.*)$ /book.php?url=$1 [L]这是我的阿帕奇的error.log:
[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.我错过了什么,为什么是重定向循环?
发布于 2012-08-01 06:19:30
你写的RewriteRule似乎在试图做与你的问题标题相反的事情。你说你想要htaccess rewrite /book.php?id=1234 to /book/1234但是你的RewriteRule
RewriteRule ^(.*)$ /book.php?url=$1 [L]正在添加查询字符串参数。
下面的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]发布于 2018-10-25 15:18:24
尝尝这个!
# 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 你的任务完成了。
https://stackoverflow.com/questions/11696718
复制相似问题