htacces index.php?id=value to /value.html


htacces index.php?id=value to /value.html

>我有 2 个我想用 htaccess 更改的网址应该很容易,但我很难使用它:

index.php?id=Agenda/agenda.html?id=Agenda也要/agenda.html

我试过了

RewriteRule ^(.*[^/])/?$ index.php?id=$1  [L,NC]

和它的一些变化,但我无法让它工作任何建议?

您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /(?:index'.php)?'?id=(.+?)'s [NC]
RewriteRule ^ %1.html? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^([^.]+)'.html$ ?id=$1 [L,QSA,NC]