需要有关htaccess的帮助才能将文件夹重定向回root

时间:2014-03-19 16:34:21

标签: php .htaccess mod-rewrite redirect directory

我会说到这一点。我的结构文件夹如下:

root
|- app
|-- index.php
|- other_folder

我的.htaccess就像这样

<IfModule mod_rewrite.c>
    Options -Indexes
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    Rewritecond %{HTTP_HOST} ^root
    RewriteRule ^$ app/index.php [L]
    RewriteCond %{DOCUMENT_ROOT}/app%{REQUEST_URI} -f
    RewriteRule .* app/$0 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* app/$0 [QSA]
    RewriteRule ^app$ . [L,R=301]
</IfModule>
好吧,我完全不了解它。即插即用,反复试验。我让htaccess:

  1. root 访问它时,运行 app / index.php
  2. root / index.php 访问它时,运行 app / index.php
  3. 访问 root / other_folder 时仍然访问 other_folder
  4. root / app 访问时,它会重定向回 root
  5. root / app / index.php / any 访问时,它会重定向到 root / index.php / any
  6. root / index.php / any 访问时,它将运行 root / app / index.php / any
  7. 现在,问题是文件夹 app 仍然被访问,而不是重定向回 root 。所以任何人都可以帮我解决这个问题:(先谢谢,原谅我的英语不好。

0 个答案:

没有答案