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

Como instalar o WordPress em um subdiretório (passo a passo)

Nota editorial: Ganhamos uma comissão de links de parceiros no WPBeginner. As comissões não afetam as opiniões ou avaliações de nossos editores. Saiba mais sobre Processo editorial.

Deseja instalar o WordPress em um subdiretório?

A instalação do WordPress em um subdiretório permite executar várias instâncias do WordPress no mesmo domínio ou até mesmo em um nome de subdomínio.

Neste artigo, mostraremos como instalar facilmente o WordPress em um subdiretório sem afetar o nome do domínio principal.

Installing WordPress in a subdirectory or folder

Subdomínio vs. Subdiretório: Qual deles é melhor para SEO?

Normalmente, você deseja iniciar um site WordPress com seu próprio nome de domínio (por exemplo, wpbeginner.com).

No entanto, às vezes, você pode querer criar outros sites no mesmo nome de domínio.

Isso pode ser feito instalando o WordPress em um subdomínio (http://newebsite.example.com) ou como um subdiretório (http://example.com/newwebsite/).

Uma pergunta que nos fazem é qual é o melhor para SEO.

Os mecanismos de pesquisa tratam os subdomínios de forma diferente dos nomes de domínio raiz e atribuem classificações como sites separados.

Por exemplo, os mecanismos de pesquisa consideram os sites WPBeginner e WPBeginner Videos como sites separados.

Por outro lado, os subdiretórios se beneficiam diretamente da autoridade de domínio do domínio raiz e, portanto, têm uma classificação mais alta na maioria dos casos.

Uma maneira de criar sites separados do WordPress em ambos os subdomínios ou subdiretórios é instalar uma rede multisite do WordPress.

No entanto, se quiser manter dois sites gerenciados separadamente, você poderá instalar instâncias diferentes do WordPress.

Você também pode usar as ferramentas de gerenciamento de sites do WordPress para configurar um único painel de controle para gerenciar várias instalações do WordPress.

Requisitos para instalar o WordPress em um subdiretório

Não há requisitos especiais para instalar o WordPress em um subdiretório. Você está pronto para começar se já tiver um site do WordPress no nome de domínio raiz.

No entanto, se você tiver um site estático (não WordPress), talvez seja necessário verificar com sua empresa de hospedagem se ela oferece suporte ao WordPress.

Se isso não acontecer, você precisará mover seu site para outra empresa de hospedagem.

Recomendamos o uso do Bluehost. Eles estão oferecendo um desconto generoso na hospedagem para usuários do WPBeginner com um nome de domínio gratuito.

Se estiver usando um provedor de hospedagem diferente, todas as principais empresas de hospedagem WordPress facilitam muito a instalação de vários sites WordPress usando a mesma conta de hospedagem.

Por exemplo, se você estiver usando a Bluehost, poderá adicionar um novo site WordPress a partir do painel de controle da hospedagem.

Bluehost add new site

No entanto, lembre-se de que a maioria das contas de hospedagem compartilhada tem recursos de servidor limitados.

Um pico repentino de tráfego em um de seus sites afetará o desempenho e a velocidade de todos os outros sites na mesma conta.

Se você estiver apenas começando, poderá fazer isso com a hospedagem compartilhada. Lembre-se de que você precisará fazer upgrade para a hospedagem gerenciada do WordPress à medida que sua empresa crescer.

Dito isso, vamos ver como instalar o WordPress em um subdiretório facilmente.

Etapa 1: criar um subdiretório sob o nome de domínio raiz

Primeiro, você precisa criar um subdiretório ou uma pasta no site principal. É nesse local que você instalará os arquivos do WordPress.

Conecte-se à sua conta de hospedagem do WordPress usando um cliente FTP ou o Gerenciador de arquivos no cPanel.

Depois de conectado, vá para a pasta raiz do seu site. Normalmente, é a pasta /public_html/.

Você verá seus arquivos e pastas do WordPress se já tiver o WordPress instalado na pasta raiz.

Em seguida, clique com o botão direito do mouse e selecione “Create new directory” (Criar novo diretório) no menu.

Create new directory

Você precisa ter cuidado ao escolher o nome do seu subdiretório. Isso fará parte do URL do seu novo site WordPress e será o que os usuários digitarão nos navegadores para acessar esse site.

Por exemplo, se você nomear esse diretório como travel-guides, o endereço do seu site WordPress será:

http://example.com/travel-guides/

New subdirectory created

Etapa 2: Fazer upload dos arquivos do WordPress

Seu subdiretório recém-criado está vazio no momento. Vamos mudar isso fazendo o upload dos arquivos do WordPress.

Primeiro, você precisa visitar o site WordPress.org e clicar no botão “Download”.

Download WordPress

Seu navegador fará o download do arquivo zip que contém o software WordPress mais recente para o seu computador.

Depois de fazer o download do arquivo, você precisa selecioná-lo e extraí-lo.

Os usuários de Mac podem clicar duas vezes no arquivo para extraí-lo, enquanto os usuários de Windows precisam clicar com o botão direito do mouse e selecionar a opção “Extrair tudo”.

Extract WordPress

Após extrair o arquivo zip, você verá uma pasta “wordpress”.

Dentro da pasta wordpress, você verá todos os principais arquivos e pastas do WordPress.

WordPress files

Agora, vamos carregar esses arquivos em seu novo subdiretório.

Conecte-se ao seu site usando um cliente FTP e vá para o subdiretório que você criou na primeira etapa.

No painel de arquivos locais do seu cliente FTP, vá para a pasta “wordpress” que você acabou de extrair.

Selecione todos os arquivos dentro da pasta e, em seguida, carregue-os em seu novo subdiretório.

Upload WordPress files

Etapa 3: Criar um novo banco de dados

O WordPress armazena todo o seu conteúdo em um banco de dados. É necessário criar um novo banco de dados com seu novo site WordPress instalado em um subdiretório.

Primeiro, faça login no painel de controle da sua conta de hospedagem do WordPress e clique no botão “Settings” (Configurações) abaixo do seu site.

Bluehost site settings

Depois disso, vá para a guia “Advanced” (Avançado) no menu superior.

Role um pouco para baixo até a seção cPanel e clique em “Manage” (Gerenciar).

Launch cPanel dashboard in Bluehost

Isso abrirá o cPanel ou o painel de controle avançado de hospedagem.

A partir daí, clique em “MySQL Databases” (Bancos de dados MySQL) na seção Databases (Bancos de dados).

cPanel mysql database

Observação: O painel de controle da sua hospedagem pode ser diferente da captura de tela acima. Basta localizar a seção “Databases” (Bancos de dados).

Na tela seguinte, digite o nome do novo banco de dados e clique no botão “Create Database” (Criar banco de dados) para continuar.

Create new MySQL database

O painel do cPanel criará agora o novo banco de dados MySQL. Clique no botão “Go Back” (Voltar) para retornar à página Databases (Bancos de dados).

Em seguida, é necessário adicionar um nome de usuário e uma senha para o banco de dados.

Basta rolar para baixo até a seção “MySQL Users” e fornecer um novo nome de usuário e senha. Clique no botão “Create User” (Criar usuário) para continuar.

Adding new MySQL user

Em seguida, é necessário conceder a esse usuário recém-criado privilégios para trabalhar no banco de dados que você criou anteriormente.

Role para baixo até a seção “Add user to database” (Adicionar usuário ao banco de dados). Selecione seu nome de usuário do MySQL e, em seguida, selecione o banco de dados recém-criado.

Add user to database

Clique no botão “Add” (Adicionar) para continuar.

Agora, o Cpanel concederá ao usuário do MySQL privilégios totais no banco de dados recém-criado.

Etapa 4: Instalar o WordPress

Agora que tudo está pronto, você pode prosseguir e instalar o WordPress.

Visite o diretório criado anteriormente em um navegador da Web, digitando o URL da seguinte forma:

http://example.com/your-subdirectory-name/

Isso abrirá o assistente de instalação do WordPress. Primeiro, selecione o idioma do seu site WordPress e clique no botão “Continue” (Continuar).

WordPress select language

Em seguida, será solicitado que você forneça o nome do banco de dados do WordPress, o nome de usuário do banco de dados, a senha e o host.

Insira os detalhes do banco de dados e clique no botão “Submit” (Enviar).

WordPress database details

O WordPress agora se conectará ao seu banco de dados.

Depois que a conexão for estabelecida, você verá uma mensagem de sucesso como esta:

Database connected

Clique no botão “Run the install” (Executar a instalação) para continuar.

Na próxima tela, será solicitado que você forneça um título para o seu site e escolha um nome de usuário, uma senha e um endereço de e-mail para o administrador.

Enter website details

Depois de inserir os detalhes do site, clique no botão “Run install” (Executar instalação) para continuar.

O WordPress agora configurará seu site e mostrará uma mensagem de sucesso:

WordPress install finished

Agora você pode fazer login no seu novo site WordPress instalado no subdiretório.

Etapa 5: Corrigir Permalinks

Se você tiver uma instalação separada do WordPress no diretório raiz, os arquivos .htaccess do seu subdiretório causarão conflito. Isso resultará em erros 404 em seu site.

Para resolver isso, você precisa editar o arquivo .htaccess no subdiretório de instalação do WordPress. Substitua o código dentro do arquivo .htaccess pelo código a seguir:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your-subdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-subdirectory/index.php [L]
</IfModule>
 
# END WordPress

Não se esqueça de substituir /seu-subdiretório/ pelo nome do seu subdiretório.

Esperamos que este artigo tenha ajudado você a instalar o WordPress em um subdiretório. Talvez você também queira ver nosso guia passo a passo definitivo de SEO para WordPress para iniciantes.

Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.

Divulgação: Nosso conteúdo é apoiado pelo leitor. Isso significa que, se você clicar em alguns de nossos links, poderemos receber uma comissão. Veja como o WPBeginner é financiado, por que isso é importante e como você pode nos apoiar. Aqui está nosso processo 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.

O kit de ferramentas definitivo WordPress

Obtenha acesso GRATUITO ao nosso kit de ferramentas - uma coleção de produtos e recursos relacionados ao WordPress que todo profissional deve ter!

Reader Interactions

85 ComentáriosDeixe uma resposta

  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. Prem Krishnan P says

    I have installed WordPress on the subdirectory. (i.e)www.example.com/blog) and now I created a test post (i.e.)www.example.com/blog/test. Is it possible to remove the subdirectory from the url? Looking something like this example.com/test (i.e)www. Rootsitename.com/Postname

    • WPBeginner Support says

      If you want to do that then we do not have a specific recommendation to achieve that and it would likely be best to place the post on your primary domain to achieve that.

      Administrador

    • Jiří Vaněk says

      This can be done using the .htaccess file, which is the Linux apache configuration file. It is possible to upload rules to this file, which can be used to rewrite URL addresses in the browser. However, it is a relatively complex topic and it is necessary to approach such an intervention sensitively.

  3. Mangkutak says

    is this type of wordpress installation still can enable multisite feature if i want it to enable for my wordpress site. i heard that before long time ago that’s not possible, is that still the case today?

  4. Mohammed says

    hello,
    I did the same steps, once I installed WordPress and do some tests I found that cannot make save posts or publish them. an error message appears
    Updating failed. The response is not a valid JSON response.
    please help.

  5. alan says

    Thanks for this tutorial. I wasn’t sure if I had to previously create the database or make it during the install process.

  6. Giwa says

    Hello, this steps are self explanatory but in my case, our main website doesn’t run on WordPress however we want to run WordPress on a sub-directory /blog.
    How do we go about this
    the main website runs on NodeJs

    • WPBeginner Support says

      You should still be able to follow the steps in this guide for what you’re wanting to do.

      Administrador

  7. Abid Hasan says

    Today I’ve set up my new WordPress inside sub-directory. Didn’t need to change the .htaccess file. I think WP is so smart now that can handle this automatically.

    • WPBeginner Support says

      Thanks for sharing, your hosting provider may have also set it up for you when installing as certain hosts set that up for you now. :)

      Administrador

  8. Sam says

    Thank you for this guide.

    We are planning to have subdirectories on our next website. This guide really cleared the air.

    One question though,

    Is there a limited to how many subdirectories a WordPress website can have?

  9. Swetha says

    Hi.. thanks for this article… am unable to upload the folders wp-admin, wp-content and wp-includes in the sub directory… rest other files are uploaded.. how do I upload all of these???

    • WPBeginner Support says

      It would depend on why you are unable, if you reach out to your hosting provider they should be able to assist but it may be a permissions issue with your user.

      Administrador

  10. Arinze says

    Thanks it worked.
    Is it possible to the subdirectory name on the URL, for example example.com/seo/how-to-rank to example.com/how-to-rank

    • WPBeginner Support says

      If you would like your URLs not to have the subdirectory in the URL we would recommend installing the site on your primary domain rather than creating redirects to remove it from the URL.

      Administrador

  11. Arinze says

    Thanks for this article. It is very insightful.
    Will the installation of WordPress on the sub folder affect the overall speed of the site.

  12. dennis wille says

    there is an apparent error in your htaccess code example

    should be
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /your-subdirectory/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /your-subdirectory/index.php [L]

     
    # END WordPress

    note rewriterule line 5 change

    • WPBeginner Support says

      Thank you for catching that, while not specifically required, we’ll look to update the article :)

      Administrador

  13. Deddy Hidayat says

    I want to build a web with a wordpress subdirectory, the first web is domain.com, and the second web is domain.com/blog … as far as I know wordpress uses domain.com/blog as the default post … will it hurt SEO?

    • WPBeginner Support says

      WordPress does not use /blog as a default, that is only the most common URL to use. Using blog for a subdirectory should not have a major effect on SEO.

      Administrador

  14. Shashank Dubbewar says

    is it necessary to install and manage same plugins separately if I installed wordpress on main domain and sub directory each and manage wordpress sites separately ?

  15. Mohd Kaleem says

    Hello Sir, Can I create Subdirectory without login Cpanel. I forgot My Hosting Details. But I have WP details, is it possible to create subdirectory using wordpress any plugin or other way?

    • WPBeginner Support says

      You would need access to your hosting, you should be able to reach out to your hosting provider for assistance in being able to log back into your account.

      Administrador

  16. Nicoleiver says

    Hi, I would like to ask is it possible to copy all the file from my current folder to the sub directory? Because I want to have the same template and plugin for my sub directory site.

  17. John Doe says

    What if the I created a new subdirectory from another subdirectory, should the fix permalink still be relevant and work with no problem?
    For example, I have firstwebsite.com/firstsubdir/ the second subdirectory will be firstwebsite.com/firstsubdir/secsubdir/ should I still use the same fix for the permalink?

    Sorry English is not my first language.

    • WPBeginner Support says

      You would need to include the second subdirectory in the permalink change and it should still work.

      Administrador

  18. keram says

    Thanks for a clear tutorial.

    Is it possible to install WP in a subdirectory but use the main domain URL to access it and still have the main URL displayed in the browser address bar?
    To clarify:
    I would install WP in mydomain.com/sub/ but would like to access it by opening mydomain.com and have mydomain.com displayed in the browser so that visitors can bookmark my URL.

    Is it possible to set it up?

    • WPBeginner Support says

      It is possible but would depend on your hosting provider to see if it is allowed. If you reach out to your hosting provider they should be able to assist.

      Administrador

  19. Ghulam Mujtaba says

    Salam, I just finished reading the article and i have question, how can i have the same header and footer from the wordpress installation in parent directory? I’ll be glad and thankful to you if you give me a clue, Thanks…

  20. Sohail says

    Really helpful! One question please.

    Do I have to add this line:

    RewriteBase /your-subdirectory/

    for every install in a sub directory in main WordPress installation?

    Thanks

  21. Alex says

    Hi. I manually copied my WordPress files to the root folder, without the plugin. I then copied the original database in a new one, where I replaced the siteurl to reflect the new location, the root folder. In the wp-config file at the root folder, I changed WP_HOME and WP_SITEURL to remove the /wordpress.

    As a result, I was able to reach the wp-login for my new location, but no further.

    And when I visited my site, I was getting a warning “too many redirections”.

    Any advice?

  22. Abhishek mahajan says

    Thanks a lot for WP subfolders step by step guide. One thing that i never undersatnd is how to create a exact Google news xml sitemap in WordPress?

    • WPBeginner Support says

      Most SEO plugins should add the required markup for you to be able to be added to Google News. If you are using an SEO plugin you would want to reach out to the plugin’s support for what they recommend for setttings.

      Administrador

  23. Hesam says

    Thanks for your article. I have a question about transforming this sub domain or sub directory installed word press to main root of website and replace it with the main site. what should I do?

  24. Umesh Yellaboina says

    Hi Team, Thanks for this post, not only these… all the other posts in your blog are very helpful to us, I really appreciate your works. Thanks a lot for these.

    And need a little help, actually did the same as in this post, installed wordpress in a sub directory, but I’m face a little issue, i.e. I’m unable to receive the emails from contact form, when it was on sub-domain it’s working fine, but when it is installed on sub-directory not receiving the form submissions, it’s going on loading but not getting submitted. Please help me with this. Thank you.

  25. David says

    Thanks for the info. I read every post you write.

    Just I’ve a doubt. I created a new WP Install trough my Host provider, but searching, there is no .htaccess file in the subdirectory. It’s mandatory to have a new .htaccess file? it’s going to create errors in the future?

    • WPBeginner Support says

      WordPress should generate the htaccess file if you resave your permalinks. If you still don’t see it you may not have the option to show hidden files enabled :)

      Administrador

  26. Eulises Quintero says

    Hello, I successfully installed WordPress in a subdirectory around 3 weeks ago, I already uploaded a theme, some plugins and made some posts. Question, can I change the name of my subdirectory? How? the name is Chose for my subdirectory and what shows after my original website URL is español, I want to make it es, I want to change this because I read somewhere that characters like ñ might cause some issues in terms of SEO….so now I’m worried, thank you for your time

  27. Mosiur Rahman says

    Hey, I just followed the process except i haven’t changed the htaccess file. My site is still working properly. I am using hostinger.

    is changing the htaccess mandatory ? will it cause error in the future?

    • WPBeginner Support says

      Your host may have set up the redirect for you, if you reach out to your host they should be able to let you know.

      Administrador

  28. Owaiz Yusufi says

    Just got it to work but little bit worried, does it increases my load time of both pages. I mean to say that

    ( currently I have made this on localhost for test but I am going to implement it in one or two days on my main server )

    I have two website but single domain

    Just want to know that does this will increase the bandwidth useage and load time.

    Let’s suppose if I my main webpage size 1 mb and my second website size is also 1 mb so when someone load the main page does it loads all the 1+1 2mb size.

    • WPBeginner Support says

      Hi Owaiz,

      Yes it will increase bandwidth usage depending on your traffic. Since both WordPress installs share the resources, traffic load on one website will affect the performance of other website as well.

      Administrador

  29. Karen says

    Hello, I dont understand something. What is the difference between installing wordpress in a subdirectory and just creating multiple pages???

    I am a noob

  30. Simson says

    I think I did everything as shown in your instructions. But the trouble I’m having is when I’m trying to customize my theme on the subdirectory it taking me to the root domain wp customizer. What should I do then… ?

  31. Yoki andika says

    Hello, can you help me?

    I installed my local wordpress to the subdir with ftp but the problem is the css doesn’t work properly, and i don’t know what’s wrong with my wordpress, because i follow this step.
    Maybe Anyone can help?

    Thank you

  32. Kandra says

    Hi,

    I am following the steps that you have recommended in creating the sub directory, but than I see the following error,

    When I trying to open the URL after uploading all the files to the folder through FTP,
    I see the URL redirecting to wp-admin/setup-config.php & throwing an server error 500 (This page isn’t working
    simplyrent.in is currently unable to handle this request.
    HTTP ERROR 500)

  33. Jyotishman Nath says

    I have heard that subdirectories are treated as part of root domain in terms of ranking.But my subdirectory is not ranking, even for exact match keyword search.I have indexed Subdirectory using Fetch as Google Tool.I don’t know what is the problem?

    I have submitted it to Search Console, Created separate robot.txt and sitemap (Sitemap is pending from last two days).

    Should I give more time to Google to Crawl by Subdirectory?

    Please Replay.
    Thanks!

    • WPBeginner Support says

      Hi Jyotishman,

      It is up to search engines to decide how they would rank your website in their results. All you can do is optimize your website for SEO and follow the best practices.

      Administrador

  34. Layon says

    Thank you for this tutorial. It saved me after hours trying to understand why I was getting 404 errors all day long.

  35. TH says

    Question: Login for main and subdirectory

    Hi. I created a subdirectory with a separate WP install.
    It looks like the user has to create an account for the main and subdirectory and to login for both the main and subdirectory.

    Is there a way to let a user who has login to either the main or subdirectory site to have access to the other site without having to login again? i.e if user has login into main site, he/she does not need to login to the subdirectory site. and vice versa.

    Thanks.

    TH

  36. Dragos says

    By default, if you are using softaculous, you are installing wordpress to the default directory named wp. You don’t need to install manually WordPress in a directory/ subdomain, you only need to change the name of the directory where you want Softaculous to install WordPress and it will also make a database and so on. :)

  37. medmouncef says

    Thanks for this tutorial.
    It would be interesting to show, when you have a little time of course, how to configure cPanel redirects to this subdirectory. For example, I can’t redirect my domain name to a WordPress subdirectory créé sous /public-html.

Deixe uma resposta

Obrigado por deixar um comentário. Lembre-se de que todos os comentários são moderados de acordo com nossos política de comentários, e seu endereço de e-mail NÃO será publicado. NÃO use palavras-chave no campo do nome. Vamos ter uma conversa pessoal e significativa.