简体   繁体   English

需要从Kohana内置的网站的网站网址中删除www

[英]Need to remove www from site URL's for a site built in Kohana

I'm looking for the correct place(area) to put my code snippet to remove WWW from URL 我正在寻找正确的位置(区域)来放置我的代码段,以从URL中删除WWW

The site is in Kohana and the code written to remove 'www' is: 该网站位于Kohana,删除“ www”的代码为:

$host_name = $_SERVER['HTTP_HOST']; // it stores the host name / domain name
$tmp_host = substr($host_name, 0, 3);

if($tmp_host == 'www')
{
    $host_name = substr($host_name, 4);
}

Any help would be appreciated 任何帮助,将不胜感激

Here is what you need: 这是您需要的:

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

enter your url instead of example.com additionally this is nothing about Kohana. 输入您的网址,而不是example.com,这与Kohana无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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