do targeting with htaccess

0

I have a project where when the user types the site with www, it gives error. I checked the server and it does not have any htaccess in the root folder. With this, I would like to know how to make the user enter www.site.com.br or link to be directed to the site folder p     

asked by anonymous 03.08.2017 / 19:51

2 answers

1

Because the file does not exist, just create it in your root folder!

And add one of these codes, which suits your situation better:

Redirect addresses without www to addresses with www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^seusite.com.br
RewriteRule ^http://www.seusite.com.br%{REQUEST_URL}[L,R=301]

Redirect URL's with www to an address without the www

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,L]
    
03.08.2017 / 20:08
1

Try the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^seusite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.seusite.com$
RewriteRule ^(.*)$ http://www.seusite.com/site [R=301,L]
    
03.08.2017 / 19:59