【发布时间】:2014-07-09 15:11:02
【问题描述】:
我正在使用 .htaccess 文件将所有请求重定向到位于子文件夹中的 index.php 文件。
文件夹和文件结构:
/var/www/html/.htaccess
/var/www/html/my-folder/index.php
主 html 文件夹中只有 .htaccess 文件和 my-folder 目录。
我的 .htaccess 文件内容是:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /my-folder/index.php [L]
实际上所有请求都被重定向到正确的位置,即 my-folder 中的 index.php 文件。所有请求,但请求 url 只是主机名。例如:
www.my-host.com/path -> Redirects correctly
www.my-host.com/path/ -> Redirects correctly
www.my-host.com/path/another-path -> Redirects correctly
www.my-host.com/file.php -> Redirects correctly
www.my-host.com -> Won't redirect
www.my-host.com/ -> Won't redirect
我做错了什么?
【问题讨论】: