开发者

How to setup a root domain mirror for a subdomain using .htaccess or php

开发者 https://www.devze.com 2023-01-25 15:35 出处:网络
I want a subdomain to mirror the root-domain (ex: sub.root.com mirroring 开发者_如何转开发root.com) and I want to accomplish this via .htaccess or php, with .htaccess prefered. RewriteCond %{ENV:REDIR

I want a subdomain to mirror the root-domain (ex: sub.root.com mirroring 开发者_如何转开发root.com) and I want to accomplish this via .htaccess or php, with .htaccess prefered.


RewriteCond %{ENV:REDIRECT_STATUS} ^$

RewriteCond %{HTTP_HOST} ^((subdomain).)?([a-zA-Z0-9-]+.([a-zA-Z]{2,3}(:[0-9]+)?))$ [NC]

RewriteRule ^(.*)$ /%{REQUEST_URI} [QSA,L]


you don't have to write any PHP code or modify .htaccess. you can accomplish this by just modifying /etc/hosts (Linux) or %SystemRoot%/Windows/system32/drivers/etc/hosts (Windows)

0

精彩评论

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