我有以下文件夹结构:
- Frontend
- Administration
- StoreFront
我希望能够从主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文件应该保持来自前端的“可包含”。
发布于 2013-05-16 12:15:37
让我提前告诉你们,你们想要实现的是任务不可能实现的,现在让我告诉你们为什么。你有这样的规则:
RewriteRule ^(.*)$ /Frontend/StoreFront/$1再往下看你有:
RewriteRule ^(.*)$ /Frontend/Administration/$2.* ,你不能让去两个地方。你需要以某种方式区分这两条路。
除了这一点,你还有其他问题,例如:
L (最后)标志$2代替$1编辑:基于您的评论的:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(Administration(?:/.*|))$ /Frontend/$1 [L,NC]
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteRule ^$ /Frontend/StoreFront/index.php [L]
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteCond %{REQUEST_URI} !^/Frontend/StoreFront
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Frontend/StoreFront/$1 [L]https://stackoverflow.com/questions/16586920
复制相似问题