简体   繁体   中英

How to setup a domain name server on CentOS?

I deploy a site and try to login, for instance on www.website.com , but there is no login info when I go to website.com

How to make both domain as same?

Many thanks.

You don't need a domain name server to accomplish this, you can simply use a .htaccess file.

Inside the file, put the lines:

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

What this does is looks at the URL entered by the user, and if it does not start with www. then it prepends it to the URL and redirects. So entering in website.com , will redirect to www.website.com .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM