重定向.COM在.htaccess以.org等 [英] Redirect .com to .org in .htaccess

查看:135
本文介绍了重定向.COM在.htaccess以.org等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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.

这篇关于重定向.COM在.htaccess以.org等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆