htaccess reading files from folder (web alias)
i have in ROOT folders root_public, root_about, root_maps
and i need to show it to this sample:
- domain.com <- everything from _public
- domain.com/about AND domain.com/about/ 开发者_运维知识库<- everything from _about
- domain.com/maps AND domain.com/maps/ <- everything from _maps
but i don't know, what i will do with root_public\maps .. it could be problem. so how i can resolve this problem? because i need this structure. and how i can do this?
i am using:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ _public/$1 [NC]
this to read everything from file _public but i don't know, how to do subfolders!
thank you!
Based on your question, I am assuming you have a directory structure that looks like:
/your/document/root/_public
/your/document/root/_about
/your/document/root/_maps
...where the Apache DocumentRoot
is /your/document/root
.
The following would work, though I'm sure there are neater solutions.
# add trailing slash to domain.com/about and domain.com/maps
RewriteRule ^/(about|maps)$ /$1/
# rewrite domain.com/about/something to /_about/something
RewriteRule ^/(about|maps)/(.*) /_$1/$2
# rewrite anything that doesn't start about/ or maps/ to _public
RewriteCond %{REQUEST_URI} !^/(about|maps)/
RewriteRule ^/(.*) /_public/$1
精彩评论