Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Copa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Cómo trasladar correctamente WordPress de un subdominio al dominio raíz

Nota editorial: Ganamos una comisión de los enlaces de socios en WPBeginner. Las comisiones no afectan a las opiniones o evaluaciones de nuestros editores. Más información sobre Proceso editorial.

¿Desea trasladar un sitio WordPress de subdominio a dominio raíz?

El proceso es bastante fácil de seguir, y hay una manera de guardar o ahorrar, según contexto, sus rankings SEO.

En este artículo, le mostraremos cómo mover fácilmente WordPress de subdominio a dominio raíz con instrucciones paso a paso.

Moving a WordPress site from subdomain to root domain

Transferencia de WordPress del subdominio al dominio raíz

Un subdominio es una extensión de su nombre de dominio raíz. Por ejemplo, http://yourwebsite.example.com es un subdominio de ejemplo.com. En este caso, ejemplo.com es el dominio raíz.

Los motores de búsqueda consideran que el subdominio es un sitio web totalmente diferente. Por eso debe asegurarse de redirigir correctamente los motores de búsqueda al dominio raíz después del traslado. Esto le ayudará a mantener los rankings de búsqueda después de trasladar su sitio web.

A diferencia de trasladar un sitio WordPress a un nuevo alojamiento o a un nuevo nombre de dominio, trasladar un sitio al dominio raíz es un poco más fácil.

Principalmente porque ambos suelen estar alojados en la misma empresa de alojamiento web. Esto le permite omitir algunos pasos.

Veamos cómo trasladar un sitio WordPress de subdominio a dominio raíz.

Paso 1. Crear una copia de seguridad completa de su sitio web Cree una copia de seguridad completa de su sitio web

Siempre debe mantener una solución de copia de seguridad instalada en su sitio web para realizar copias de seguridad automáticas. Hay un montón de plugins de copia de seguridad de WordPress que puede utilizar para mantener su contenido de WordPress seguro.

Ahora, si usted ya tiene un plugin de copia de seguridad instalado, entonces usted puede estar pensando que puede omitir este paso.

Este paso es para recordarte que incluso si tienes copias de seguridad automatizadas de tu sitio web, todavía necesitas crear una copia de seguridad completa de tu sitio. Esto incluye una copia de seguridad de la base de datos, así como una copia de seguridad de todos los archivos y carpetas de WordPress.

Una vez que haya creado una copia de seguridad completa, asegúrese de almacenarla en una ubicación remota o en su ordenador.

Paso 2. Trasladar los archivos de WordPress del subdominio a la carpeta raíz Trasladar los archivos de WordPress del subdominio a la carpeta raíz

En primer lugar, debes conectarte a tu sitio web mediante un cliente FTP o el gestor de archivos de cPanel. Una vez conectado, vaya a la ubicación de su subcarpeta y descargue todos los archivos de WordPress en su ordenador.

Download WordPress files

A continuación, abra la carpeta public_html de su dominio raíz. Dependiendo de cómo esté establecido su entorno de alojamiento de WordPress, esta carpeta también podría llamarse www o con el nombre de su dominio.

Ahora, necesitas subir todos los archivos de WordPress que descargaste anteriormente al directorio raíz.

Upload WordPress files to root domain

Paso 3. Cambiar los ajustes de URL de WordPress y URL del sitio

Una vez que mueva los archivos de WordPress, no podrá acceder al área de administrador de WordPress en el dominio raíz. Si intenta acceder al sitio web raíz, volverá al área de administrador del sitio web del subdominio.

Para corregir esto, cambie al cliente FTP y vaya al directorio raíz de su nombre de dominio. A continuación, edita el archivo wp-config.php y añade las siguientes líneas justo antes de la línea “Eso es todo, ¡deja de editar! Feliz blog”.

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

No olvide sustituir ejemplo.com por su propio nombre de dominio. Si desea que su sitio web raíz utilice www, entonces tendrá que introducir las URL con el prefijo www.

Guarde los cambios y vuelva a subir el archivo wp-config.php a su sitio web.

Ahora puede visitar el área de administrador de su sitio WordPress en el dominio raíz.

Paso 4. Actualización de las URL

Su sitio de WordPress se ha trasladado al dominio raíz, pero habrá enlaces dentro de su base de datos de WordPress que apunten al subdominio.

Vamos a corregirlo.

Necesitará instalar y activar el plugin Go Live Update URLs. Para más detalles, consulte nuestra guía paso a paso sobre cómo instalar un plugin de WordPress.

Tras la activación, debe visitar la página Herramientas ” Go Live desde su panel de administrador de WordPress.

Select core tables to update

En la parte superior de la página, puede marcar / comprobar si desea actualizar las URL de sus entradas, comentarios, opciones, datos de usuario, condiciones y otras áreas.

A continuación, desplácese hasta la parte inferior de la página. Aquí tienes que introducir la URL de tu subdominio junto a la opción “URL antigua” y añadir tu dominio raíz como “URL nueva”.

Enter old and new URL

Una vez que haya terminado, haga clic en el botón “Actualizar URL” para continuar.

El plugin ahora actualizará todas las URLs en su base de datos de WordPress.

Paso 5. Redirigir todo el tráfico del subdominio al dominio raíz

Ahora que ha movido los archivos de WordPress, vamos a asegurarnos de que el tráfico de su subdominio se redirige al nombre de dominio raíz.

Vaya a la carpeta de su subdominio y asegúrese de que los archivos ocultos están forzados a ser visibles.

Los ajustes de su cliente FTP tienen una opción para mostrar siempre los archivos ocultos. En FileZilla, se encuentra en la opción Servidor ” Forzar mostrar archivos ocult os.

Show hidden files

Si utiliza el Gestor de Archivos de cPanel, haga clic en el botón “Ajustes” situado en la esquina superior derecha de la pantalla. Aparecerá el mensaje / ventana emergente de preferencias. Debe seleccionar “Mostrar archivos ocultos” y luego hacer clic en el botón “Guardar”.

Show hidden files in cPanel file manager

Si la carpeta de su subdominio ya tiene un archivo.htaccess, puede borrarlo y crear uno nuevo. Dentro del nuevo archivo .htaccess, debe copiar y pegar el siguiente código:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursubdomain\.example\.com$ [NC]
RewriteRule ^(.*)$ "http://example.com/$1" [R=301,L]
</IfModule>

No olvides sustituir tu subdominio por tu subdominio real, y example.com por tu nombre de dominio.

Tenga en cuenta que la línea RewriteRule utiliza una URL que no es www. Si desea utilizar www en su dominio raíz, entonces tendrá que añadir su URL con un prefijo www.

Guarde los cambios y suba el archivo .htaccess al servidor.

Eso es todo. Ha trasladado correctamente su sitio del subdominio al dominio raíz. Ahora puedes visitar tu sitio web para verlo en acción. Pruebe su sitio web para asegurarse de que todo funciona correctamente.

Esperamos que este artículo te haya ayudado a trasladar tu sitio de subdominio a dominio raíz. Puede que también quieras ver nuestra guía definitiva de SEO para WordPress para principiantes, así como nuestra selección de los mejores plugins de redirección 404 para WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Descargo: Nuestro contenido está apoyado por los lectores. Esto significa que si hace clic en algunos de nuestros enlaces, podemos ganar una comisión. Vea cómo se financia WPBeginner , por qué es importante, y cómo puede apoyarnos. Aquí está nuestro proceso editorial .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

El último kit de herramientas de WordPress

Obtenga acceso GRATUITO a nuestro kit de herramientas - una colección de productos y recursos relacionados con WordPress que todo profesional debería tener!

Reader Interactions

63 comentariosDeja una respuesta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Heidary says

    hello and thank you for this article
    i moved a website from subdomain to domain but the problem that i have is when i enter the subdomain url in the browser the website is being displayed but the url that is being displayed in the address bar is the subdomain , and when i click one of the links on the website then i am being redirected to main domain , please note there is nothing on the subdomain right now.
    i do have 301 redirect on the subdomain but something doesn’t seem to be working properly , any idea what could be causing this? any help or tip would be appreciated
    thank you in advance

    • WPBeginner Support says

      If you’ve already done the step to update your URLs, we would recommend checking your Settings>general page to ensure the URL was updated correctly there.

      Administrador

  3. Jesse Dill says

    I am going through the steps and on step 3, I followed the php syntax but it caused some errors and I couldn’t get to any of the wordpress admin sites. I had to remove the pre tags and just use:

    define(‘WP_HOME’,’http://example.com’);
    define(‘WP_SITEURL’,’http://example.com’);

    After that it worked. Just in case anyone comes across the same issue as me.

  4. sarah says

    Hi, Step two doesn’t seem to work for me as CPanel won’t let me download the directory sub.example.com

    I can download individual files but not folders or directories. I have tried compressing to .zip but the .zip file is empty.

    Can you please advise? Many thanks

  5. Jessica says

    I see that Velvet Blues Update URLs plugin on wordpress.org is noted “This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.”

    Do you recommend a different plugin now or to still use this one?

  6. Caleb Byers says

    Do you need to update anything in the databases after doing the steps in the article? Whenever moving a site I’ve seen people say that there are a few steps in the databases, but not in this article… Is there a reason why?
    Thanks.

  7. Del Abernethy says

    Worked a charm up until I tried to login to wp-admin. The site already had files (which I over-wrote) and users but now it won’t recognise the existing users. It does allow me to login using the username & password from the sub-domain so I’m assuming it is linked to the sub-domain database. Is it possible to link it to the existing original database?

    • WPBeginner Support says

      You would want to check the wp-config file for the database it is connected to for your site and you would be able to change that in your file. That would normally happen if you didn’t overwrite the existing file if you were trying to replace a site with the one on the subdomain.

      Administrador

    • WPBeginner Support says

      It would depend on what references you are talking about. If you mean links in the articles then the velvet blues plugin updates those.

      Administrador

    • WPBeginner Support says

      You would likely want to check with your hosting provider to ensure they don’t have a firewall and your SSL certificate is active as the most common reasons

      Administrador

  8. Ben says

    Hey – do you reccomend also using Googles change of address tool, to tell it subdomain.primarydomain.com is now primarydomain.com ?

    thanks

    • WPBeginner Support says

      If you want you can also use that tool, the redirects would normally resolve this for you.

      Administrador

  9. Sara says

    Hi,
    I followed your steps up until the end of step 3, where I have edited the wp-config.php file
    I then go to the wp-admin. I enter my details and it just goes back to the same login. It’s not allowing me to login to the wordpress backend.
    It’s like it’s redirecting me.
    Are you able to help?
    I’d really appreciate it.
    Thanks,
    Sara

  10. Sofia says

    Hello, I did everything and it worked! But now I’m wondering, how do I keep my subdomain as a “staging” website, so that I can change things and not affect the one on the domain. I’d have to make a new database (using a backup) right?
    How to assure I don’t do anything wrong?

  11. Oliver says

    In my subdomain folder, I have 2 .htaccess files. One is in subdomains/example, the other is in subdomains/example/web. The latter is next to all the other wordpress files. Which one should I delete and replace with the code in step 5?

    • WPBeginner Support says

      You may need to check with your host but from the sound of it, you would modify the second one.

      Administrador

  12. Aldo Salim says

    Hi, thank you so much for the great help.

    However, i do not want to keep the old sub-directory folder. Will it be okay to delete the sub-directory folder?

  13. Joshua Orizu says

    I am building a websites and the domain name is displaying site.comp50 instead of site.com how do i fix this

    • WPBeginner Support says

      You may want to check with your hosting provider to ensure the correct domain is attached to where your site is and then you would be able to update the url in your Settings>General area

      Administrador

  14. Jeremy says

    What happens to the blog posts on the root domain during a migration?

    I currently built a redesigned site on a subdomain, Sandbox.WebsiteName.com, and want to migrate it over to the the root domain. However, I want to keep the blog posts.

    i’m worried about the seo. Do the blog post from the root domain get overwritten? If not how would i access them to redirect them?

    Thanks,

  15. Madison says

    Hi,

    Would this method work if I wanted to move a subdomain, which a friend uses, ie, xxx.example.com, over to their new account so it can be its own website like xxx.com?

    If not, is there anything that would work at all or would they just have to start over, thus losing all the comments, page views, etc?

  16. Rui says

    Hi,
    This tutorial is great, but didn’t work for me. I don’t know why.

    I can access to admin area, in homepage the images are not shown and when i tried to access posts and products says “Not Found
    The requested URL /shop/index.php was not found on this server.”

    I would like some help if possible.
    Thank you a lot

    • WPBeginner Support says

      You may want to ensure steps 3 and 4 were completed for the most common reason for that.

      Administrador

    • Canonical Bear says

      Hi,
      We had the same problem (my team and I). Only the Home Page would open, and all other pages were broken.
      You need to update the permalinks. Go to Dashboard ->Settings -> Permalinks. Here, don’t make any changes, just click on “Save Changes”.
      It re-apply settings with the current directory as root.
      All the best.

  17. Milan says

    Hello WP Team,

    just one quick question… what is the difference between this procedure and clone website from cpanel installatron (godaddy). Can I use clone for same purpose? Do I need to made some additional changes after cloning. It’s looks much easier to do this with clone option.

    Thanks for good work!

  18. Melind says

    This worked like a charm! The part that takes the longest is uploading and downloading the files. Thank you!

  19. smv says

    This didn’t work for me at all. Step 4, using the Velvet Blues plug-in to update the URLs, didn’t update most of them. There were still loads of references to the old site. I had to re-do everything, but I used the duplicator plug-in, which worked well.

  20. Gábor Sztárcsevics says

    Hi!

    Is this modification will change the records in the database, which is used for my wordpress on the subdomain.example.com?

    Shouldn’t I create a new database for the migrated wordpress?

    Thank you!

    • WPBeginner Support says

      Hi Gábor Sztárcsevics,

      Since you are moving from subdomain to root domain on the same hosting environment, your old database would work just fine after you update URLs as shown in the tutorial.

      However, if you would like to create a new database, then you can do that as well. You will then need to export your data from the old database to the new one and update URLs.

      Administrador

  21. Shravan says

    RewriteCond %{HTTP_HOST} ^yoursubdomain\.example\.com$

    in this code, do i need to remove those 2 backward slash’s

  22. Denise says

    I don’t see where you remove the old wordpress files. Are they automatically replaced when you upload the subdomain files to the root?
    Thank you.

  23. Charlotte Jones says

    I tried this and got a HTTP 500 error. Luckily I backed everything up, but I don’t understand. All the files are there in public_html and I changed the wp-config file to point to the root domain.

  24. Jon says

    Very good thank you. Went like a dream apart from an error I made by amending the old subdomain .htaccess file instead of the new one in the root. Your advice was excellent tho.

  25. Juan F. says

    Hi guys,

    After doing all the steps, if I want to save a page I get an error and automatically redirects me to the post list, could you help me please?

    Thanks in advance.

    • Anita says

      Hello!
      If I make the site in the exemple.com/Wordpress folder, do I have to move it to the example.com folder or can I just redirect it, how does that work?
      /Anita

  26. Ousman Faal says

    This was definitely useful. I was just about to change a demo site on a sub domain to a root domain.
    You guys are live savers.

Deja tu comentario

Gracias por elegir dejar un comentario. Tenga en cuenta que todos los comentarios son moderados de acuerdo con nuestros política de comentarios, y su dirección de correo electrónico NO será publicada. Por favor, NO utilice palabras clave en el campo de nombre. Tengamos una conversación personal y significativa.