Domain without www does not work

Asked

Viewed 2,723 times

1

At the root of the server I have a folder "wp" where I have Wordpress installed. I put inside the folder because the site was not made with Wordpress and yes the blog.

When typing the url "www.dominio.com/wp" the blog opens without problems, but if type "domain.com/wp" (without www) does not work.

I already tried the solutions I found on Google, for example, edit the . htaccess inside the "wp" folder to always redirect to "www", but it doesn’t work and always redirects from "dominio.com/wp" to "www.dominio.com".

The .htaccess is as follows:

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

How do I solve the problem?


UPDATE: 21/10/2014
After having access to the control panel in Godaddy, I found that some DNS settings were missing in Godaddy.

The added settings were:

  • A (host):
    @ -> point to its IP
    meusite -> point to its IP
    www.meusite -> point to the respective IP

  • Cname (alias) www -> point to meusite.com

3 answers

5

This setting is not from .htaccess, yes from the virtual host. In the file you configure your domain (for example, /etc/apache2/sites-enabled/dominio.conf), just configure the ServerAlias:

ServerName  www.dominio.com
ServerAlias dominio.com

2

Also using the .htaccess, if you do not have access to the Virtual Host, you may have something like this at the root of your domain:

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

The redirect will be done, regardless of the "directory" you are.

  • But this implies that the project receives the requisitions from the domain without www, right?

  • Yes, as I understand it, he wants to redirect from the domain without the www towards the www, which is also a good practice not to duplicate content.

  • I get it. In this case we are proposing to solve its problem (which is to respond to both domains) and to redirect the requests from one of the domains to the other. I find the idea valid. :)

  • At the root of the site I created htaccess with the above code and when typing domain.com/wp does not redirect par www.dominio.com/wp, then I removed this and edited htaccess inside the wp folder and does not redirect.

  • Okay, since you created a new one, you need a .htaccess complete. I edited my reply. And if you have access to Virtual Host, @Rodrigorigotti’s solution is simpler.

  • I changed as per your example and "dominio.com/wp" does not redirect to "www". I do not have access to Virtual Host.

  • Well, that’s weird because I have a domain that works just like that. Another case of mine and that you can try, is to put this code right above yours, even in .htaccess of wp. Mine is thus.

Show 2 more comments

0


After having access to the control panel in Godaddy, I found that some DNS settings were missing in Godaddy.

The added settings were:

  • A (host):
    @ -> point to its IP
    meusite -> point to its IP
    www.meusite -> point to the respective IP

  • Cname (alias) www -> point to meusite.com

Browser other questions tagged

You are not signed in. Login or sign up in order to post.