简体   繁体   English

如何使用.htaccess或php为子域设置根域镜像

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

我想要一个子域来镜像根域(例如:sub.root.com镜像root.com),并且我想通过.htaccess或php来完成此操作,首选.htaccess。

RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond%{ENV:REDIRECT_STATUS} ^ $

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

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

you don't have to write any PHP code or modify .htaccess . 您不必编写任何PHP代码或修改.htaccess you can accomplish this by just modifying /etc/hosts (Linux) or %SystemRoot%/Windows/system32/drivers/etc/hosts (Windows) 您只需修改/etc/hosts (Linux)或%SystemRoot%/Windows/system32/drivers/etc/hosts (Windows)即可完成此操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM