开发者

How can I accomplish this type of mod_rewrite?

开发者 https://www.devze.com 2023-02-15 08:35 出处:网络
I would like to setup a staging and production environment on one shared server. So, optimally, I would like to be able to create a structure lik开发者_如何学运维e the following on the server:

I would like to setup a staging and production environment on one shared server. So, optimally, I would like to be able to create a structure lik开发者_如何学运维e the following on the server:

/stage/
   /lib/
   /web/
      /js/
      /css/
      index.php
      ...
/production/
   /lib/
   /web/
      /js/
      /css/
      index.php
      ...

However, although I am able to change the document root of an added subdomain or addon domain, I am unable to change the document root of the primary domain. So, I am stuck with the document root being /public_html/.

I would like the staging environment to be accessible through stage.domain.com (pointing to /stage/web/), and every other subdomain, *.domain.com or domain.com, route to the production environment (pointing to /production/web/).

With that in mind, I believe I need a robust mod_rewrite script to do the job (.htaccess level). Since, I am a novice at mod_rewrite, does someone know how to write a script that will transparently route the requests appropriately?

or

Is there a better way to handle these two environments on a shared server?


If you can't change the document root of main domain. Can you create a symlink in public_html name production folder to /web/production. Enable symlinks.

RewriteCond {REQUEST_FILENAME} !-f
RewrireRule ^(.*)$ production/$1 [QSA,L]
0

精彩评论

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