使用`.htaccess`默认访问`folder / index.php`?

时间:2013-01-13 10:21:08

标签: .htaccess rewrite subdirectory

我想将其设为默认值:

从:

mydomain.com/folder/folder/

为:

mydomain.com/folder/folder/index.php

无论如何要做.htaccess

1 个答案:

答案 0 :(得分:0)

这会将所有两个级别的文件夹从/f1/f2/重定向到/f1/f2/index.php,并在地址栏中显示。它没有重定向/f1/f2/f1/script.php(没有斜杠)

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !index\.php   [NC]
RewriteCond %{REQUEST_URI}  ^/(\w+)/(\w+)/$
RewriteRule .*       %1/%2/index.php               [R,L]