开发者

Get apache to serve different site to developers for same URL

开发者 https://www.devze.com 2023-01-16 07:48 出处:网络
The customers existing site is running nicely on the server from /home/nfc/public_html at the URL www.example.com.

The customers existing site is running nicely on the server from /home/nfc/public_html at the URL www.example.com. We've developed a new site under /home/nfc2/public_html and this has been checked by using a development URL such as nfc2.dev.example.com.

But now I want to test for various links etc and check all works as expected.

Is th开发者_C百科ere a way I can get Apache to serve me the new site if I browse to www.example.com but still show everyone else the old site.

It may be possible by using SetEnvIf REMOTE_ADDR type stuff to give me a specific site due to my IP address.

This may seem like not really needed - but the reason is that we have developed six sites at the same time and they all have many links between them - and currently those links go to the dev addresses so the customer could check all sites at the same time. I'd like to view the new sites on their new URL's so I can check all links have been altered.


You can just use a RewriteRule with the appropriate RewriteCond using mod_rewrite.

Example on remote_host:

RewriteEngine on
RewriteCond   %{REMOTE_HOST}  !^.+\.ourdomain\.com$
RewriteRule   ^(/~.+)         http://www.somewhere.com/$1 [R,L]

Or by address:

RewriteCond %{REMOTE_ADDR}       ^123\.45\.67\.[8-9]$
0

精彩评论

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

关注公众号