How to successfully redirect URLs in htaccessHow to successfully redirect URLs in htaccessHow to successfully redirect URLs in htaccessHow to successfully redirect URLs in htaccess
  • Overview
      • For Industry
        Introduce self-optimizing and self-learning systems into the production process. Use the power of artificial intelligence (AI) to produce much faster and more efficiently.
      • For Ecommerce
        Automate your CRM data, emails, SMS, push messages with one unified omnichannel personalization workflow and response in real-time based on qualitative data.
      • For Business
        Optimize all business processes from accounting and HR, to contracts and customer relationship management. Connect online with offline and grow with ease.
  • Capabilites
  • Blog
  • Company
  • Login
Request 10-min call
✕
09/02/2018

Typically, redirecting the domain to a different address is not a problem, especially if we have CMS systems that allow the smooth addition of 301 redirects. Especially in WordPress, which have so many plugins allowing us to quickly modify and add redirections.

In an equally simple way, we can manage redirections of individual subpages, eg if we have optimized part of the URLs or removed outdated content from the website. Just upload the .csv file or set the redirection manually. We then have the certainty that it will work immediately and without a problem.

The issue looks different when the domain within which we set up redirections does not have a convenient CMS. Then we have to use the htaccess file. This is much more problematic, especially for a positioner who previously had no contact with this rather capricious file. This article is just for you. I have prepared a few rules that can facilitate this difficult task.

The method of redirecting individual addresses

Redirecting a single URL in htaccess is not a big problem. We do it with the rule:

Redirect 301 /old-website https://domain.com.au/new-website

This way you should also redirect the entire domain, if you change not only the domain address but also URL addresses within the site (eg due to optimization activities). This complicates the whole process much, but that’s where the Excel and it formulas come for rescue. Paste the redirection matrix into the file, and in the third column enter the formula:

=CONCATENATE("Redirect 301 ";A1;" ";A2;)
With the help of the formula, we combine both columns! Just copy the last column and paste it into the htaccess file. Unfortunately, this is just the beginning of our struggle.

Enter the main domain address at the very end of the list. It is unintuitive, but thanks to this you will avoid problems with redirection of all of the following addresses. Remember that htaccess executes commands from the top rather than as a whole. Some rules at the beginning of the file may affect subsequent redirections.

Test redirections

Each time you set a new rule or redirect in htaccess, test it. It sounds obvious but in the case of htaccess it makes a lot of sense. Sometimes a situation may happen in which a single redirection begins to live its own life. You better discover them before the algorithm! Use tools for this if the site is large, or try out the URLs from the file randomly.

Get along with Google

Of course, as a positioner, on Google you feel like a kid in a candy store. When setting redirections in htaccess you will be able to test your research performance. When finding solutions for problems with htaccess, you’ll find that there are a lot of them, but not every one of them will work on your redirections. Pay attention to the rules preceding redirections, as they may interfere with the indications below.

Prepare for unexpected problems with the htaccess file, because it can be unpredictable, especially for the person who associates it only with the exclusion of certain parts of the website from the watchful eye of the algorithm.

Redirecting URLs with spaces and brackets in htaccess

Redirecting URLs with spaces

Unfortunately, redirections in htaccess do not cope with various wrong URLs containing unusual characters such as spaces or brackets. The result of attempts to route these types of addresses by the standard method can be generating addresses returning error 404. To avoid such problems, trace all occurrences of spaces in the document (they are encoded as% 20).

Try the following formula:

Redirect 301 “/old url with spaces” domain.com.au/new-url-without-spaces

Where each instance of the %20 combination URL is swapped for space. It is important to include the URL with spaces in quotation marks – this tells the redirection that it is to pay attention exactly to the address indicated. Instead of using spaces, you can also try the following combinations:

Redirect 301 “/old\ url\ with\ spaces” domain.com.au/new-url-without-spaces
Redirect 301 “/old\surl\swith\sspaces” domain.com.au/new-url-without-spaces
Redirect 301 “/old[\s]url[\s]with[\s]spaces” domain.com.au/new-url-without-spaces

Redirecting URLs with brackets

We do the same when there are brackets in our addresses. Brackets are another sign with which traditional redirection can not handle. The idea is to reuse the trick from the previous subsection.

Redirect 301 “/old-url\(with-bracket\)”domain.com.au/new-url-without-bracket

Before every bracket, I inserted a backslash, indicating that this is part of the address and a full-fledged character, not a fragment of the formula. In this way, the changed URL should be redirected to the desired address without any problem.

Redirecting addresses in htaccess requires from us more knowledge and the ability to prepare the file. We must remember about such issues as the correct set of formulas and modify them appropriately, depending on the needs (eg in the case of brackets and spaces and special characters). This is not the simplest thing, and it can take us a surprisingly long time. As a result, however, we get well-functioning redirects that convey the traffic and value of the landing page.

Share
54
Firecrux Crew
Firecrux Crew

Related posts

10/11/2021

What is E-A-T and what does it mean for Google?


Read more
09/14/2021

The future of natural language processing – NLP


Read more
08/13/2021

Google’s spam update


Read more
07/30/2021

What is Performance Marketing?


Read more

Leave a Reply Cancel reply

You must be logged in to post a comment.

Firecrux Logo

Platform

  • Capabilites
    • For Industrial Production
    • For Ecommerce
    • For Business
    • Customer Account
    • Documentation
    • Request PoC

Company

  • Company
    • Brand Manual
    • Careers
    • Partner Program
    • Sitemap
    • Contact

Resources

  • Blog
    • Use Cases
    • AIRE – AI Response Engine
    • CDP – Customer Data Platform
    • Send Us Your Design

Legal

  • Terms of Use
    • Privacy Policy
    • Security Commitment
    • Data Protection Officer
    • Data Control Panel
    • Accessibility Statement
2016- © Firecrux.com
By using Firecrux.com you accept the terms of use.
Request 10-min call