使用.htaccess将所有请求重定向到另一个域,但保留原始url


redirect all requests to another domain using .htaccess but keeping the original url

我有一个运行在CMS.com上的CMS,它处理我所有客户的登录。目前,我的客户必须访问cms.com才能访问面板。

我希望他们使用自己的域(如customerdomain.com/admin)访问相同的CMS,同时保留URL。

那么,一个给定的请求,比如posts.php?id=1,以cms.com/posts.php的形式访问?id=1是否应被customerdomain访问为customerdomain.com/admin/posts.php?id=1

RewriteEngine On
RewriteRule "^admin/(.*)$" "http://cms.com/$1" [P]

我们已经解决了使用A类型DNS记录的问题。我们所做的是,为每个客户端创建了一个子域(admin.sitename.com)和一个指向CMS服务器IP的子域admin.sitename]的类型记录。