问题描述
我已经在AWS centos实例的cpanel托管中设置了一个域我可以不使用www前缀来浏览我的网站,但是当我将www放入浏览器时,它会转到cgi-sys/defaultwebpage.cgi
I have setup a domain in cpanel hosting in AWS centos instanceI can browse my website without www prefix but when I put www in browser it goes to cgi-sys/defaultwebpage.cgi
已经为www创建了cname记录,并且我检查了该cname的ip地址是否已在DNS工具中显示.
The cname record is already created for www and I have checked that ip address for this cname is showing in DNS tool.
我已经尝试过清除浏览器缓存,但是没有运气.
I have tried by clearing the browser cache but no luck.
如果我尝试使用邮递员(没有任何浏览器),那么它将返回以下html:
If I try using postman (without any browser) then it returns following html:
<html>
<head>
<META HTTP-EQUIV="Cache-control" CONTENT="no-cache">
<META HTTP-EQUIV="refresh" CONTENT="0;URL=/cgi-sys/defaultwebpage.cgi">
</head>
<body></body>
</html>
这意味着当我主要从浏览器尝试时,它会转到存在该html的页面,稍后它将重定向到/cgi-sys/defaultwebpage.cgi页面
that means when I try from browser primarily it goes to a page where this html is present, later it redirects to /cgi-sys/defaultwebpage.cgi page
谁能告诉我问题出在哪里以及如何解决.
Can anyone tell me what is the problem and how to fix it.
===编辑===
我当前的htaccess是:
my current htaccess is:
RewriteEngine On
RewriteRule ^backend/(.*)$ /backend/$1 [L,QSA]
RewriteRule ^testbackend/(.*)$ /testbackend/$1 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
我也尝试在htaccess中添加以下几行,但没有运气:
i also tried by adding following lines in htaccess but no luck:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
我什至尝试删除htaccess文件.即使是像 http://wwww.mydomain.com/test.txt 这样的静态文件也不是工作
even i tried by removing the htaccess file. even a static file like http://wwww.mydomain.com/test.txt is not working
如果我向www请求,请求就无法到达应用程序
it seems if i request with www, the request not reaching to application
此信息是否有助于识别问题?
is this information help to identify the issue?
推荐答案
在 public_html
中检查您的 .htaccess
文件并附加代码:
check your .htaccess
file in public_html
and append code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^yoursite\.com$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
或
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
这篇关于域名不适用于www,但不适用于www的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!