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.

Redirection 301 with .htaccess

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.

Free apps to learn other languages Technology in learning In recent decades, ...
Change left image alignment right in WordPress Some time ago I noticed a certain disorder i...
5 Data Privacy Goals to Set This Year The year is still young, and many peopl...

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.


One option was to replace them manually, another was to look for a broken ...

The Sun is the most important star for life on Earth, but it is also ...

In computer science (discipline dedicated to the management of information...

These days it happened that I needed to cut out a song that, at the beginn...

Bibliography ► (June 18, 2019). Redirection 301 with .htaccess. Recovered from

About the author

This article was published by Phoneia, originally published in and titled "Redirection 301 with .htaccess", along with 19037 other articles. It is an honor for me to have you visit me and read my other writings.