我在example.com/go/
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /go/?there=$1 [L]
因此example.com/go/ttt.html
变为example.com/go/?there=ttt
但我不想要任何扩展程序,我想删除.html
,所以我尝试了:
RewriteEngine On
RewriteRule ^([^/]*)$ /go/?there=$1 [L]
但它不起作用,example.com/go/ttt
提供内部服务器错误
如何正确做到?
答案 0 :(得分:0)
尝试添加此行:
RewriteCond %{REQUEST_FILENAME}.html -f
所以,代码将是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^/]*)$ /go/?there=$1 [L]
然后测试example.com/go/ttt
UPDTAE:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ /go/$1.html [L]
RewriteRule ^([^/]*)\.html$ /go/?there=$1 [L]