Redirection 301 with .htaccess

Making a 301 or 302 redirect really is not something that someone use or think will use a lot or very frequently. However, over time perhaps one or another event may arise that leads to the need to do so, for one or another circumstance.

As we said, for this we will only need to add at the end of our Apache .htaccess a line of code that will do all the work.

Redirect only one page

If we are only going to redirect a page to a new domain or subdomain, we can enter this code:

redirect 301 /url_antigua.html

To do this, it is sufficient to indicate the url of origin in a relative way, while the url of destination must be indicated in an absolute way.

Redirect all pages to a single page

When creating a web one can create many pages or post. If we want each and every one of them to direct to a single url of destination, we can do it in a massive way. Example of this would be: to a a at

As we can see, there is a massive redirection, from all the URLs of one domain to the root of another domain. And we do it by just attaching to .htaccess this:

redirectMatch 301 ^ (. *) $

Paired, or paired, redirection

Now, maybe we have the same post and the same URL in the origin and destination, maybe in another domain or subdomain, and we want to do the redirection in bulk.

An example of how this would work is like this: to to at at

Well, the solution is very simple. Simply attach this code snippet:

redirectMatch 301 ^ (. *) $ http: //$1

You can redirect to either a domain or a subdomain or subdirectory, including a subdirectory.

In this post we have put the examples with code 301 (which indicates that the url has been moved permanently); However, if it is only temporary, we can change 301 to 302. That’s it. I hope it has served you and, importantly, it has been easy to understand.


Redirection 301 with .htaccess
In the territory of SEO, it is always good to review the keywords of our w...

Photo by Ivan Samkov from Pexels What’s the point of purchasing NFTs...

On the web we find all kinds of resources, for all types of people and nee...

The domain market is something really big and, within the network, is an e...

Bibliography ► (June 18, 2019). Redirection 301 with .htaccess. Bogotá: E-Cultura Group. Recovered from