Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a web site to work without www prefix in its name?

Tags:

url

apache

web

Normally, I drop www when typing in the URL. Frankly, one important site I visit, don't support such shorted URL and I want to ask them to fix it.

Is a solution a configfile fix? Or does it require a special provider-related service?

like image 610
psihodelia Avatar asked Dec 13 '22 15:12

psihodelia


1 Answers

If they have Rewrite Engine enabled, they can create .htaccess file with this rule

RewriteEngine on

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

This way everyone who comes to http://example.com is redirected to http://www.example.com automatically.

like image 97
mike Avatar answered Feb 19 '23 14:02

mike