我发现了一个问题,与此类似,但似乎并没有为我(Make web root folder a sub-folder with .htaccess?)工作。所以我寻求帮助后,无法找到我的问题的任何答案 - 我花了2个小时在放弃之前通过了200多页的结果在stackoverflow。反正...的.htaccess地图子目录根
我创建一个小的CMS,并有我的目录结构的设置是这样的:
application
-- html
-- -- public
-- -- -- theme
-- -- -- -- css
-- -- -- -- images
-- -- -- -- js
-- -- -- forum
-- -- -- -- index.php
-- -- -- -- viewforum.php
-- -- -- -- viewthread.php
-- -- -- -- comment.php
-- -- -- index.php
-- -- -- login.php
-- -- -- profile.php
-- -- admincp
-- -- -- theme
-- -- -- -- css
-- -- -- -- images
-- -- -- -- js
-- -- -- index.php
-- -- -- manage.php
-- -- -- users.php
-- -- -- settings.php
-- plugins
library
我试图做到的是映射mydomain.com/application/html/public要的index.php和mydomain.com/index.php与admincp其mydomain.com/admincp/index.php。因此,它看起来像公共目录中的所有内容都位于根目录中。
当我查看mydomain.com时,它显示了../public/中的index.php文件,但是当我尝试mydomain.com/index.php时,我得到一个未找到的错误。当我去mydomain.com/admincp或mydomain.com/admincp/manage.php它的工作原理though--如果你知道使它更好地让我知道的一种方式。 :)
RewriteEngine on
RewriteRule ^$ application/html/public/
#RewriteRule ^(.*)$ application/html/public/$1 # Breaks site
RewriteCond %{DOCUMENT_ROOT}/admincp !-f
RewriteRule ^admincp/(.*)? application/html/admincp/$1
RewriteRule ^admincp$ admincp/ [L]
我很感激任何帮助,建议,讽刺,我可以在这个问题上得到。
- 编辑 -
@迈克尔与投放我的目的 这是结果的答案给我提供了:
RewriteEngine on
# Don't need this...
#RewriteRule ^$ application/html/public/
# Need [L] and a RewriteCond
# Don't do the rewrite if this is an actual existing file
# such as what is rewritten into application/html/public
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# And don't write admincp into public
RewriteCond %{REQUEST_FILENAME} !admincp
# With the above conditions met, write anything else into the public dir
RewriteRule ^(.*)$ application/html/public/$1 [L]
# Then just write admincp into application/html/admincp
RewriteRule ^admincp/(.*) application/html/admincp/$1 [L]
现在我只需要在我的目录来解决这个问题索引显示观看根时 - mydomain.com/
- 编辑 -
,当我在 RewriteRule ^$ application/html/public/
添加回它没有突破,所以它看着像它像它应该!
它的工作原理!但是当我的东西添加像'^重写规则论坛/ $应用程序/ HTML /公/ forum.php [L]'新规则不起作用。 :( – Zythaera
@Zythaera看到变化在底部上方... –
谢谢,它的工作原理。我开始明白htaccess的好一点。 – Zythaera