【发布时间】:2013-05-11 07:35:00
【问题描述】:
我有以下文件夹结构:
- www-root
- 后端
- 配置
- 等
- 前端
- 管理
- 店面
- 后端
我希望能够从主 url 访问目录并隐藏其间的子目录。
所以我应该可以像这样访问管理部分:
http://localhost/Administration/
主页面存储在子目录“StoreFront”中,我希望能够从根目录访问:
http://localhost
到目前为止,这是我的 .htaccess 文件中的代码:
# Store Redirect
RewriteEngine on
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteCond %{REQUEST_URI} !^/Frontend/StoreFront
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Frontend/StoreFront/$1
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteRule ^(/)?$ /Frontend/StoreFront/index.php [L]
RewriteCond %{REQUEST_URI} !^/Administration
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Frontend/Administration/$2
但此代码无法正常工作。它将除 index.php 文件之外的所有文件重写到 Administration 子目录。附注:后端目录中的 php 文件应从前端保持“可包含”。
【问题讨论】:
标签: .htaccess web directory rewrite subdirectory