install WordPress in subdirectory and display at domain root

install WordPress in subdirectory

📅 Publicado el 31 de octubre, 2026 · Por Equipo RedServicio

Cuando quieres install WordPress in subdirectory mientras mantienes el sitio accesible desde la raíz de tu dominio, hay algunos pasos claros que puedes seguir para lograr una configuración limpia y profesional. A continuación, te guiaré a través de la preparación del directorio, la instalación del núcleo de WordPress en esa ubicación y la configuración de enlaces permanentes para que todo parezca estar en la raíz de tu dominio. Con estos consejos prácticos, evitarás errores comunes y podrás desplegar tu nuevo sitio rápidamente.

Setting Up Your Subdirectory

El primer paso es crear un subdirectorio en tu servidor web que albergue la instalación de WordPress. Este directorio debe estar separado de los archivos principales del sitio (si los tienes) para mantener un mejor orden y facilitar las actualizaciones futuras.

1. Elegir el nombre del subdirectorio

Decide un nombre que sea breve y relevante, por ejemplo blog, app o nuevo. El subdirectorio residirá dentro de tu raíz pública (por ejemplo, /public_html/blog).

2. Crear el directorio

Usa el cliente FTP o la consola para crear el directorio:

  • FTP: Arrastra y suelta para crear una nueva carpeta.
  • SSH: mkdir /path/to/your/root/blog

Asegúrate de que los permisos de carpeta sean 755 para permitir la escritura del propietario y la lectura/ejecución para los demás.

Consejo: Si planeas utilizar un subdirectorio para un blog o aplicación separada, considera añadir un archivo .htaccess para forzar HTTPS en esa área más adelante.

Con el directorio preparado, estás listo para descargar y configurar WordPress dentro de él.

Installing WordPress in the Subdirectory (install WordPress in subdirectory)

Descarga el núcleo más reciente de WordPress desde wordpress.org. Luego, extrae los archivos en el subdirectorio que acabas de crear. Este proceso coloca los archivos necesarios de WordPress dentro de un nuevo árbol de directorios.

1. Descargar WordPress

wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz

A partir de la versión 6.4, también puedes usar curl. Transfiere el archivo wordpress extraído al subdirectorio usando tu cliente FTP o la consola.

2. Mover los archivos

  • FTP: Arrastra la carpeta wordpress a tu subdirectorio (por ejemplo, /public_html/blog).
  • SSH: mv wordpress/* /path/to/your/root/blog

Elimina la carpeta wordpress vacía si lo deseas.

3. Configurar wp-config.php

Abre wp-config.php en un editor de texto y modifica las constantes de base de datos. También ajusta el prefijo de tabla para mayor seguridad. Guarda los cambios y sube el archivo a tu servidor.

4. Ejecutar el script de instalación

Navega a tu subdirectorio a través de un navegador (por ejemplo, https://example.com/blog). El script de instalación detectará automáticamente el directorio y guiará a través del proceso de configuración. Elige un título para el sitio, una contraseña y proporciona tus credenciales de base de datos.

Una vez que el sitio esté activo, prueba todas las páginas y publicaciones para asegurarte de que funcionen correctamente dentro del subdirectorio.

Configuring Permalinks and URLs for Root Display

Para que los visitantes vean el sitio como si estuviera en la raíz de tu dominio, debes ajustar la configuración de enlaces permanentes y, si es necesario, editar el archivo .htaccess o los archivos de configuración del servidor.

1. Ajustar la configuración general

En el panel de administración de WordPress, ve a Configuración → General. Establece la dirección de WordPress (URL) y la dirección del sitio (URL) ambas a tu subdirectorio. Esto indica a WordPress dónde está alojado el núcleo.

2. Ajustar los enlaces permanentes

Navega a Configuración → Enlaces permanentes. Selecciona Nombre de publicación o cualquier estructura que incluya el subdirectorio. Luego, guarda los cambios para escribir la nueva estructura en el archivo .htaccess.

3. Forzar la redirección a la raíz

Si deseas que las URL aparezcan como https://example.com en lugar de https://example.com/blog, añade una regla de reescritura en tu archivo .htaccess raíz (no en el archivo .htaccess de WordPress). Esto redirige las solicitudes a la raíz del servidor mientras sirve el núcleo de WordPress desde el subdirectorio.

Pregunta frecuente

¿Necesito un DNS adicional? No. Tu DNS actual apunta al servidor raíz; el subdirectorio se maneja internamente a través de la configuración de WordPress y las reglas de reescritura.

Updating wp-config.php and .htaccess for Seamless Access

When you shift WordPress into a subdirectory—say, /blog—the core files need to know where to serve content from. The two files that steer this are wp-config.php and .htaccess.

Modifying wp-config.php

Open wp-config.php in whatever editor you prefer and drop two constants near the top, just before the line that says /* That's all, stop editing! */.

Tip: Setting WP_HOME and WP_SITEURL prevents mixed‑content warnings and helps plugins auto‑detect the correct URLs.

  • Define the home URL as the domain root: define('WP_HOME', 'https://www.example.com');

  • Define the site URL as the subdirectory: define('WP_SITEURL', 'https://www.example.com/blog');

Save the file and push it up to the same spot as before. WordPress will start spitting out links that look like they sit under the main domain, even though it reads the files from the subdirectory.

Configuring .htaccess for Rewrite Rules

Even though WordPress lives in /blog, you probably want URLs such as https://www.example.com/post-slug to work. Slip the mod_rewrite rule that WordPress ships with into your .htaccess.

  1. Open or create .htaccess in the root directory (where your index.html or existing .htaccess lives).

  2. Insert the following block at the end of the file (make sure RewriteEngine On is already there):

<pre>RewriteRule ^([^\?\/]+)\/?([^\?\/]+)?$ /blog/index.php?p=$1$2 [L,QSA]</pre>

That rule grabs the slug you asked for and forwards it to WordPress core, which serves the content from the subdirectory. Don’t forget to allow overrides for .htaccess in your hosting control panel; RedServicio’s 24/7 crew can double‑check permissions if you need them.

Testing, SEO Optimization, and Going Live

Testing the Setup

After you save those files, pop over to your domain and see what’s there. You should get the WordPress front end, and clicking “Read More” should land you on a full‑post URL that lives under the root domain. A tool like BrowserSync or RedServicio’s own scanner can verify that internal links, images, and feeds all resolve correctly.

SEO Best Practices

  • Canonical URLs: WordPress will automatically set the canonical tag to the root domain when WP_HOME is defined, but run a quick check with an SEO inspection tool.

  • Redirect non‑www to www (or vice‑versa): Add a rule in .htaccess like RewriteCond %{HTTP_HOST} ^example\.com$ RewriteRule ^ https://www.example.com/$1 [R=301,L] to consolidate link equity.

  • Sitemap: Generate a sitemap.xml from the WordPress dashboard and ping Google Search Console. Make sure the sitemap points to root URLs, not subdirectory paths.

Doing these steps makes sure search engines see a clean, single presence for your site.

Going Live

When you’re ready to flip the switch, update the DNS A record if you haven’t already, and flush the cache on both the server and any CDN layers. Run a final health check: confirm the SSL cert covers the root domain, all media files load, and the admin login redirects to /blog/wp-admin.

With RedServicio’s reliable hosting and round‑the‑clock support, you can launch a fully functional WordPress site that appears at the domain root while keeping the install tucked away in a subdirectory.

Conclusion

By editing wp-config.php and .htaccess correctly, you get smooth access to your WordPress site from the domain root while the core files stay safely tucked in a subdirectory. Rigorous testing, SEO tweaks, and a careful go‑live routine keep performance spot‑on and rankings strong. RedServicio’s high‑quality hosting and nonstop support let you concentrate on growth instead of technical hiccups, delivering a professional online presence your audience will trust.

📝

Equipo RedServicio

Artículos escritos y revisados por nuestro equipo técnico especializado en hosting e infraestructura web en España.

¿Listo para un hosting de verdad?

Servidores en España · Soporte 24/7 en español · Migración gratuita

Ver Planes desde 3,95€/mes →

Te puede interesar:

Página Gratis — Crea tu web gratis

Clisec — Seguridad informática

Scroll al inicio