How do you get the site to be accessed with and without "www"

Asked

Viewed 267 times

1

my site is only accessing without the "www" within the directory of my website, there is a . htaccess with this rule:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdominio\.meusite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.subdominio\meusite\.com$
RewriteRule ^(.*)$ "http\:\/\/subdominio\meusite\.com\.br/$1" [R=301,L]

I use Centos and Apache. Do I have to see any Rewrite module shutdown if it is active or inactive on my server? How do I do it?

And another problem is that my pages are only being accessed with the extension at the end: . php, . html etc. How can I fix this too?

1 answer

2

For the extensions problem check your apache’s conf file for the parameter dir_module, if you don’t have add the following lines:

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

Restart apache and test, this allows the files index.html or index.php in the site root folder within apache be opened automatically to the user Ex: what was previously accessed with www.meusite.com.br/index.php can now be accessed with www.meusite.com.br, the names index.html and index.php are commonly used as default (if not default for your case add the filename of the root directory of the apache server you want to open).

About your website access need to contain the www at the beginning you will need to create an entry DNS, if you use the Bind as DNS server you must have the zone referring to your site created, it is very likely that you have something like this on your DNS server.

zone "meusite.com.br" {
        type master;
        file "/etc/namedb/remote/meusite.com.br.zone";
};

go to the file meusite.com.br.zone and create the input www to your website:

www            IN      A       XXX.XX.XX.XX (IP publico do seu servidor web)

If this IP already has a registered name what usually happens create an entry CNAME, Increment the serial of the DNS conf file and restart the DNS service so that your DNS input can spread around the world.

Browser other questions tagged

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