我想通过 htaccess 为 PHP 网站使用 mod rewrite。
网址结构如下:
example.com/ex.php?ez=DF004AE
它必须变成:
example.com/ex/DF004AE.htm
添加到我的 .htaccess 中的正确脚本是什么?
最佳答案
使用这个:
RewriteEngine On
RewriteRule ^ex/([^/]*)\.htm$ /ex.php?ez=$1 [L]
它将为您提供以下 URL:
example.com/ex/DF004AE.htm
如果您打算将其设为 .html(而非 .htm),只需在 RewriteRule 中添加 l。
关于php - 使用 Mod Rewrite 更改 URL 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38326734/