使用.htaccess进行Mod_Rewrite

时间:2013-05-26 05:35:48

标签: .htaccess mod-rewrite

我试图把这个“index.php?page = Home”变成这个“index / Home”或者只是“Home”。 我试着阅读这个“http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/”,但仍然无法弄清楚如何去做。有什么帮助吗?

这是我的代码

RewriteEngine On
RewriteRule    ^index/([A-Za-z0-9-]+)$   index.php?page=$1    [NC,L]    # Handle requests for "index"

1 个答案:

答案 0 :(得分:0)

尝试添加“?”在变量的末尾([A-Za-z0-9 - ] +)

RewriteEngine On
RewriteRule    ^index/([A-Za-z0-9-]+)?$   index.php?page=$1    [NC,L]    # Handle requests for "index"