Skip to main content




El archivo .htaccess en WordPress te posibilita hacer ciertos cambios y mejoras en tu Web. Lo mejor de todo es que una vez que sabes cómo localizarlo y hacer cambios en este fichero todo es más fácil.

What is the .htaccess file in WordPress?

El archivo .htaccess en WordPress es un simple archivo que se ocupa de establecer ciertas configuraciones asociadas con el server Web Apache (The vast majority of hostings that host WordPress websites work with Apache).

We can say in a single line that:

The .htaccess file is an Apache configuration file.

Which means that this simple file contains some instructions associated with the operation of the server.

Este archivo se encuentra en el root directory de nuestro sitio y cuenta con una particularidad.

The file .htaccess it is, by default, a hidden file.

We cannot see it with the naked eye and that is why it begins with a period.

The .htaccess also has no extension.

What does the .htaccess file do in WordPress?

Ok, we already know that this file takes care of Apache configuration, but that doesn't tell us much.

In practice, the default .htaccess file in WordPress fulfills a very specific function:

It takes care of managing the way in which the permanent links of your website are displayed.

You know, we are talking about link structures like:

EXAMPLES.

Cada vez que cambias esta link structure o la forma en la que tu sitio mostrara los links this file is modified.

In some cases the .htaccess file it is created for the first time on your website or Blog de WordPress en el momento en que decides qué tipo de estructura de enlaces mostrará tu sitio.

On most WordPress websites, this is all this file does: manage the permalink structure.

But it is not the only thing, with this file we can achieve other things that are quite useful for our website.

How to find and edit the .htaccess file in WordPress?

There are several ways to find and modify the .htaccess file in WordPress.

Let's look at the first, and one of the best ways:

You remember that the .htaccess file is actually in the root directory, in the hosting where our WordPress website is installed.

It is for this reason that we have to log in in our Hosting and have access to file directory.

This is something that we can do at the same time via FTP, pero por el browser al mismo tiempo podemos hacerlo de forma rápida y sin complicaciones.

Para editarlo, todo lo que tenemos que hacer es posicionar el cursor sobre el archivo, presionar click derecho y seleccionar la opción:

View / Edit.

With the file open you can make all the changes you want.

An important caveat:

You have to keep in mind that the modifications and changes that you make and save in the .htaccess file of your website in WordPress cannot be undone.

That means you can break your website if you're not careful.

But beware that there are several ways to avoid disaster, take note:

Make a backup copy of the .htaccess file:

Todo lo que tienes que hacer es ubicar el archivo .htaccess, descargarlo y ponerlo a salvo en tu ordenador (puedes enviarte una copia por email o guardarlo en Google Drive, recuerda que a la vez es un archivo muy liviano)

Make a backup of your website:

This point is very important, so important that we already dedicate an entry to the subject.

If you want to delve into the whole topic of backups or Backups of your web (which we recommend):

Here you have the entrance

What if I can't see the .htaccess file in the root directory of my website installation?

As you know the .htaccess file is a invisible file a hidden file.

To see it all you have to do is enable the option of:

View or show hidden files in your host's file manager.

La ubicación de la opción podría variar ligeramente en función de la versión del software que use tu host, pero es fácil encontrarla.

Sometimes it happens that, although you have followed everything to the letter (you activated the option to show hidden files and files), the .htaccess file does not appear anywhere.

In that case you shouldn't worry.

Why can't I see the WordPress .htaccess file?

This is especially the case on “new” websites to which not many changes have been applied.

To fix it go to your website, log in and have access to the WordPress dashboard.

TuPaginaWeb.com/wp-admin/

Once you are logged in look for the option:

Settings - Permalinks

Now all you have to do is save the changes.

Yes, as you read it, you don't need to make any changes to the structure of your permanent links.

That alone will generate the .htaccess file.

The next thing is to go to host, specifically to root directory, refresh the view (with F5 or reload) and voila,

You should be able to see the .htaccess file.

How to modify the .htaccess file in WordPress easily without having to access the host?

If you are looking to modify the .htaccess file but do not want to have access on your server, you are in luck because there are several options to edit the .htaccess file without having to go to the root directory.

There are dedicated plugins that make it easy for you to manage the .htaccess file.

But we don't yearn to overload our WordPress installation with more plugins.

Es por este motivo que aprovecharemos un plugin que de seguro ya está instalado en tu web.

It's about the plugin: Yoast SEO.

This plugin has an option that allows you to modify various files on your website:

As the sitemap, the robots.txt y, de todos modos:

The .htaccess file.

How to modify .htaccess with Yoast SEO

To modify the .htaccess file with Yoast SEO you must log in and, on your WordPress dashboard, find the tab:

SEO

Hover over the tab that says: SEO.

SEO Tools

Now you will see several options.

Select the option:

Tools.

When you press the tools option you will see a settings panel.

tools settings panel

To work with the .htaccess file you must select the option:

File editor.

The first thing you will see will be the robots.txt configuration options

But if you go down just a little bit you will see the .htaccess file options.

WordPress htaccess file

From that .htaccess tab that Yoast SEO provides you, you can do everything you need without having access to the files section of your hosting.

What can I do with the .htaccess file?

With the .htaccess file you can do several cool things.

One of the things you can do with .htaccess in WordPress is 301 redirects.

It's pretty straightforward once you know how to find and modify your .htaccess file, pay attention:

To create a redirección 301 todo lo que tienes que hacer es sustituir las siguientes urls por tus urls:

Redirect 301 /LaPáginaVieja https://www.TuWebEnWordPress.com/LaPáginaNueva

At the same time as 301 redirects you can increase the size of the files that you can upload to your WordPress website.

First you must find out what is the maximum file size allowed on your website.

Once you know the size of the file, all you have to do is paste these lines into your .htaccess file:

 

php_value upload_max_filesize 256M

php_value post_max_size 256M

php_value max_execution_time 300

php_value max_input_time 300

 

256M is the new maximum size, but you can change that amount to your liking.

The best thing is that with the .htaccess file you can still do more things to promote your website, we talk about: security and other settings that can improve your experience and that of your website visitors.

If you want to discover them you can sign up to best online course in Spanish of WordPress.