How to make my site open without www

WordPress

First of all, let’s answer the question of whether it is better to have a site with www or without www. The answer is simple: it’s a matter of choice, and there is no better or worse option. However, if you start using one, do not mix them, i.e., do not use some links with www and others without www.

To prevent such errors, since Google considers the same site as two separate ones if you use both www and non-www concurrently, you can create a redirection so that when someone types www.yourwebsite.com, they are redirected to https://yourwebsite.com.

First you need to change in your Dashboard Settings then General to remove www from site url in both fields. If you skip this step you will maybe get error “too many redirects”.

This can be achieved with a simple redirect in the .htaccess file.
If you are using cPanel, log in, find the File Manager.
Then, in the public_html folder, find the .htaccess file (with a dot). If you don’t see it, click on “Settings” in the top right corner and check the box for Show Hidden files and folders. The .htaccess file will appear.

If you are using WordPress, your .htaccess file should look like this:

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

Ispod “RewriteEngine On” dodate sledeće:

RewriteCond %{HTTP_HOST} ^www\.yourwebsite\.com [NC]
 RewriteRule ^(.*)$ http://yourwebsite.com/$1 [L,R=301]

Finally, the entire .htaccess file should look like this:

# BEGIN WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.vassajt\.com [NC]
RewriteRule ^(.*)$ http://vassajt.com/$1 [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

For other websites

Save this in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Scroll to Top