htaccess - 将URI转换为重定向作为参数

时间:2017-09-08 07:09:29

标签: php apache .htaccess mod-rewrite

我在.htaccess

中有这一行
RewriteRule ^potato/?$ /potato.php

所以当我输入:

example.com/potato/

我会得到:

example.com/potato.php

但是,出于特定原因,我需要更改以下网址:

example.com/potato/

example.com/

因为potato.php要求网址中有一些流程是这样的。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

好吧,如果你坚持使用重写,你可以使用以下规则:

RewriteRule ^(/)?$ /potato.php

但是,我认为使用Apache的DirectoryIndex指令会更好,所以将它添加到.htaccess中:

DirectoryIndex potato.php index.php index.html