在.htaccess

时间:2017-02-22 12:06:07

标签: .htaccess

我想要做的事情应该很简单:当管理员写www.example.com/admin时,我希望他写信给www.example.com/admin/admin_index.php

我写了这个规则,我在Stackoverflow上检查了其他帖子:它看起来似乎是正确的,但实际上并没有用。

RewriteEngine   On
RewriteRule     ^/admin/?$ /admin/admin_index.php [L,NC]

有没有人知道为什么重定向不起作用,因为它"保持"在www.example.com/admin输出(显然)403错误?

1 个答案:

答案 0 :(得分:2)

无需使用重写规则。只需在DirectoryIndex中使用admin/.htaccess指令:

DirectoryIndex admin_index.php

当请求admin/admin_index.php

时,这将加载http://domain.com/admin/