0

如何让 Apache 重写所有 URL,例如:

mydomain.com/index.php?name=about-me

与任何一个合作

mydomain.com/about-me

或者

mydomain.com/about-me/

如果 URL 是 mydomain.com/about-me,则应该加载 mydomain.com/index.php?name=about-me。

此外,如果 URL 是 mydomain.com/about-me/,mydomain.com/index.php?name=about-me 也应该加载。

4

1 回答 1

0

在您的 .htaccess 文件中使用 mod_rewrite 包含此规则以将 name=whatever 重写为whatever/

RewriteRule ^([a-z-]+)/?$     index.php?name=$1  [NC,L]
于 2013-04-06T18:00:46.363 回答