drwo2014 2014-05-28 15:34
浏览 114
已采纳

htaccess将www重定向到非www是无情地从谷歌带来缓存副本?

I have a non www setup for a domain X.com.bd . when typed www.X.com.bd it gives a net::ERR_NAME_NOT_RESOLVED error and brings cached copy suggestion page from google. I've written an .htaccess rule as

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

And here is my whole .htaccess snippet :

  <IfModule mod_rewrite.c>
   # Turn on URL rewriting
   RewriteEngine On
   RewriteBase /

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

   # Protect application and system files from being viewed when the index.php is missing
   RewriteCond $1 ^(application|system|private|logs)

   # Rewrite to index.php/access_denied/URL
   RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

   # Allow these directories and files to be displayed directly:
   RewriteCond $1  ^(index\.php|robots\.txt|favicon\.ico|public|assets|resources|css|js|images|_assets|img)

  # No rewriting
   RewriteRule ^(.*)$ - [PT,L]

  # Rewrite to index.php/URL
  RewriteRule ^(.*)$ index.php/$1 [PT,L] 

  </IfModule> 

Now all I need is to redirect www.X.com.bd to X.com.bd

Any help is appreciated and thanks in advance.

  • 写回答

1条回答 默认 最新

  • douji2520 2014-05-28 15:36
    关注

    This is not a htaccess problem (it's not even apache related).net::ERR_NAME_NOT_RESOLVED means that there is no DNS resolution possible for www.X.com.bd. You will need to add www.X.com.bd to the DNS zone of x.com.bd. Your domain registrar/webhost will most likely have a control panel where you can do this. Otherwise their support staff should be able to help you with this.

    You should add a CNAME or A record (and/or AAAA if your server uses IPv6), like:

    www.X.com.bd. IN CNAME X.com.bd
    

    Or:

    www.X.com.bd. IN A 127.0.0.1 // But then with your actual server's IPv4 address
    www.X.com.bd. IN AAAA ::1 // Replace with your server's IPv6 address
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据