标签:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # protect xmlrpc <Files xmlrpc.php> Order Deny,Allow Deny from all </Files>
<?php setcookie("C_language","en",time()+31536000,"/"); header("Location: http://www.website.com"); ?>
.htaccess内容如下
#### Rewrite Browser Germany Language RewriteCond %{HTTP_COOKIE} !.*C_language.* //不存在cookie RewriteCond %{HTTP:Accept-Language} ^de [NC] //浏览器为DE语 RewriteRule ^$ http://www.website.com/de [R=302,L] RewriteCond %{HTTP_COOKIE} ^C_language=de [NC] //cookie 为de语 RewriteRule ^$ http://www.website.com/de [R=302,L]
代码解释:
初次进入网站,不存在C_language,浏览器为DE语,会打开www.website.com/de/页面
初次进入网站,不存在C_language,浏览器为EN语,会打开www.website.com
若用户点击了EN / CN 切换按钮,会生成C_language的Cookie,若Cookie为DE,进入www.website.com/de/页面。反之进入www.website.com
之后的用户访问均会根据Cookie做相对应的跳转
A、自身服务器做转换
RewriteCond %{REQUEST_URI} Download_File_For_.*\.exe$
RewriteRule Download_File_For_.*\.exe$ File_Setup.exe
B、跳转到CDN下载服务器做转换
RewriteCond %{REQUEST_URI} Download_File_For_.*\.exe$
RewriteRule ^(.*) http://cdn.website.com/$1 [L,R=permanent]
下载服务器:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule Download_File_For_.*\.exe$ File_Setup.exe
代码解释
所有用户下载Download_File_For_***.exe的文件,文件名会是Download_File_For_***.exe,真实的文件确是File_Setup.exe
标签:
原文地址:http://www.cnblogs.com/Mrhuangrui/p/4565416.html