提供静态内容从一个无Cookie域 - 使用子域名和.htaccess [英] Serving Static Content from a Cookieless Domain - using subdomain and .htaccess

查看:114
本文介绍了提供静态内容从一个无Cookie域 - 使用子域名和.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以有每页许多图像(如70),并希望为他们提供服务,而不cookie的开销。

I can have many images per page (e.g. 70) and want to serve them without the overhead of cookies.

我会preFER设立一个子域,并添加CNAME记录(相对于不必使用一个单独的域)。目前,我有一个CNAME记录我donmain:www.example.com ==> example.com,我想保持解析example.com到www.example.com的功能

I would prefer to set up a subdomain and add a CNAME record (as opposed to having to use a separate domain). Currently, I have a CNAME record for my donmain: www.example.com ==> example.com and I want to keep the functionality of resolving example.com to www.example.com.

我发现,当我使用访问我的网站www.example.com它使用不同的饼干,当我使用example.com的。我可以用的.htaccess重定向到www.example.com要求所有example.com的要求和解决问题的这种方式?将所有Cookie则默认为www.example.com设置什么时候?

I've discovered that when I access my site using www.example.com it uses different cookies from when I use example.com. Could I use .htaccess to redirect all example.com requests to www.example.com requests and solve the problem this way? Would all cookies then default to www.example.com when set?

更新 然后,我会创建CNAME记录static.example.com并将其指向www.example.com。然后,我会指出我所有的图像请求static.example.com。他们会是无Cookie?

UPDATE Then I would create the CNAME record static.example.com and point it to www.example.com. I would then point all my image requests to static.example.com. Would they be cookieless?

推荐答案

是的却是需要的,良好的搜索引擎优化过。多个URL的相同的内容是不是一件好事。您需要进行更改,htaccess文件写在下面。

Yes that's what is needed and good for SEO too. Multiple url for same content is not a good thing. You need to make changes in htaccess file written below.

的RewriteBase / 的RewriteCond%{HTTP_HOST} ^ example.com [NC] 重写规则^(。*)$ http://www.example.com/$1 [L,R = 301]

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

这篇关于提供静态内容从一个无Cookie域 - 使用子域名和.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆