开发者

How to dispatch / redirect to appropriate directory according to sub domain

开发者 https://www.devze.com 2023-03-01 14:04 出处:网络
I am deploying a simple website at a web host, but encounter some issues. I am quite new in this area.

I am deploying a simple website at a web host, but encounter some issues. I am quite new in this area.

My domain "example.com" 's default directory is public_html/example.com at server. (which means example.com/test.php will access public_html/example.com/test.php by default). But how can I set(config) example.com 's default directory to an sub-directory like: public_html/example.com/public/www ?

What's more: I have example.com, yy.example.com, zz.example.com, all point to public_html/example.com originally. I want them:

example.com points to public_html/example.com/public/www

yy.example.com points to public_html/example.com/public/yy

zz.example.com points to public_html/example.com/public/zz

How can I achieve this? What kind of .htacess or any ot开发者_运维知识库her appropriate ways should I use?


You can do this with a .htaccess file in your /public_html/ folder

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*) /public/www/$1 [L,NC]  

RewriteCond %{HTTP_HOST} ^yy\.example\.com$ [NC]
RewriteRule (.*) /public/yy/$1 [L,NC]  

RewriteCond %{HTTP_HOST} ^zz\.example\.com$ [NC]
RewriteRule (.*) /public/zz/$1 [L,NC]  
0

精彩评论

暂无评论...
验证码 换一张
取 消