Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect .com to .org in .htaccess

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?

like image 985
Aaron Avatar asked Apr 29 '09 17:04

Aaron


People also ask

How do I redirect a domain to another domain?

Via . Make sure to replace olddomain.com with the parked domain name and newdomain.com with your website's domain name. This will redirect all visitors for all URLs on olddomain.com to the same URL on newdomain.com. For example http://olddomain.com/awesome-page will redirect to https://newdomain.com/awesome-page.

What is 301 .htaccess redirect option?

A 301 signals a permanent redirect from one URL to another, meaning all users that request an old URL will be automatically sent to a new URL. A 301 redirect passes all ranking power from the old URL to the new URL, and is most commonly used when a page has been permanently moved or removed from a website.


1 Answers

You could use mod_rewrite to do this.

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

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

like image 165
Gumbo Avatar answered Oct 09 '22 08:10

Gumbo