如何编写重写规则,以便www.domain.com/any_path/.html是否要更改为www.domain.com/script.php?url=/any_path/.html对于任何.htm文件也应该是这样。
这将在末尾强制执行html扩展:重写规则^(.*(.html$script.php?url=$1.html
基本上:
RewriteEngine On
RewriteRule . script.php?url=$1 [QSA,L]
或
RewriteEngine On
RewriteRule ^(.*)$ script.php?url=$1 [QSA,L]
仅适用于HTML:
RewriteEngine On
RewriteRule ^(.*)'.(htm|html)$ script.php?url=$1.$2 [QSA,L]
RewriteRule ^.+'.html?$ /script.php?url=$0 [QSA,L]
请参阅最新Apache版本上的END标志。