重定向.COM在.htaccess以.org等重定向、COM、org、htaccess

2023-09-02 00:42:18 作者:哈哈酱.

我有domain.com和domain.org的别名指向同一个虚拟主机。我如何使用的.htaccess重定向所有domain.com请求domain.org?

I have domain.com and domain.org as aliases pointing to the same vhost. How can I use .htaccess to redirect all domain.com requests to domain.org?

推荐答案

您可以使用 mod_rewrite的做到这一点。

You could use mod_rewrite to do this.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^example.org$
RewriteRule ^ http://example.org%{REQUEST_URI} [L,R=301]

该规则重定向每次不是给 example.org 到同样的要求。

This rule redirects every request that’s not addressed to example.org to the very same.