域不无`www`工作(Domain doesn't work without `www`)

   IT问题网   2019-05-30 00:00:00

问 题

当我输入我的域名不一样的 www (如 http://example.com ) ,这是行不通的,并给出错误信息。然而,当我添加了 www 来它(如 http://www.example.com ),它的工作原理

这难道不是应该是双向的(有和没有 www )?

解决方案

所有你需要的是增加以下code到根的.htaccess 文件:

rewriteengine叙述上
的rewritecond%{http_host}!^ www \。
(。*)重写规则^ $ http://www.% {http_host} / $ 1 [r = 301,l]
 

标签:不无工作



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

htaccess的!-f规则不工作(.htaccess !-f rule not working)

problem i have been using simple mod_rewrite ...

"会议已经开始......"异常Zend框架应用程序("session has already been started...." exception in Zend Framework application)

problem i get this error when trying to load a zend frame ...

如何修改.htaccess文件始终重定向到www(how to modify .htaccess file to always redirect to www)

problem i would like to modify my .htaccess file so that ...

htaccess的mod_rewrite的性能(.htaccess mod_rewrite performance)

problem i searched a lot on sof about .htaccess and mod_r ...

的.htaccess:MOD重写;子域(.htaccess: mod-rewrite; subdomain)

problem i am working on a new website bud i want to creat ...

DENY使用PHP文件直接下载(DENY direct download of file using php)

problem i have .doc amp; .zip files in download directory ...

的.htaccess允许本地主机的问题(.htaccess allow localhost problem)

problem here is the situation... i have a cron job sched ...

mod_deflate模块和mod_header设置?(Mod_deflate and mod_header settings)

problem i've finally gotten a vps hosting account set up ...

要创建动态的子域在codeigniter?(Want to create dynamic subdomain in codeigniter)

problem in my site i want to add an functionality for use ...

为什么不的.htaccess有什么影响?(Why doesn't .htaccess have any effect)

problem i have a .htaccess file in a directory, but it ha ...

清洁URL重定向循环(Clean URL Redirect Loop)

problem i'm trying to create clean urls on my website. no ...

为什么不是我的JavaScript和放大器; CSS缓存?(Why isn't my javascript & css caching)

problem it's appears only javascript and css are not cach ...

包括来自的.htaccess另一个htaccess文件(Include another htaccess file from .htaccess)

problem is it possible to do include rules from another h ...

htaccess的允许访问文件,推而广之?(htaccess allowing access files by extension)

problem i saw several htaccess example disabling some fil ...

什么是.htaccess文件?(what is .htaccess file)

problem i am a beginner to zend frame work an ...

%N反向引用里面的RewriteCond(%N backreference inside RewriteCond)

problem i'm working on a virtual domain system. i have a ...

安全性如何的.htaccess密码保护?(How secure is .htaccess password protection)

problem is password protecting a directory with .htaccess ...

如何创建以用户名作为子域名子域?(How to create a subdomain with username as subdomain name)

problem i have referred other related question but they a ...

如何使Zend框架2工作,nginx的?(How to make Zend Framework 2 work with nginx)

problem i want to make zend framework 2 application to ru ...

学习的.htaccess(Learning .htaccess)

problem i would like learn about .htaccess fi ...