欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

几个ok的htaccess 有大用

shiping1 的头像

一个ok的htaccess

AddDefaultCharset UTF-8


<IfModule mod_rewrite.c>

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

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" [NC]

RewriteRule ^(.*)$ http://3g.aaa.com/ [NC,R=301]

#给在线咨询做个伪静态
RewriteRule TEL:400-6363-098$ /php/zixunbaoming.php  #好像这里只能指向某一个文件 不能指向目录 如果指向 /php/zixunbaoming 这个目录 就会跳转

RewriteCond % !^$  
RewriteRule uploads/(.*).(php)$ – [F]  
RewriteRule data/(.*).(php)$ – [F]  
RewriteRule templets/(.*).(php)$ – [F]
</IfModule>

另一个ok的 htaccess

AddDefaultCharset UTF-8
DirectoryIndex index.html index.htm index.php  

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.aaaa.com$ [NC]
RewriteRule ^(.*)$ http://3g.bbbb.com/tonew.html [R=301,L]
RewriteCond %{HTTP_HOST} ^aaaa.com$ [NC]
RewriteRule ^(.*)$ http://3g.bbbb.com/tonew.html [R=301,L]

RewriteCond %{HTTP_HOST} ^www.cccc.com$ [NC]
#RewriteRule ^$ http://www.cccc.com/index.htm [R=301,L] #其实这个也可以
RewriteRule ^$ /index.htm [R=301,L]
RewriteCond %{HTTP_HOST} ^cccc.com$ [NC]
#RewriteRule ^$ http://www.cccc.com/index.htm [R=301,L] #其实这个也可以
RewriteRule ^$ http://www.cccc.com/ [R=301,L]

</IfModule>

再一个ok 的htaccess
AddDefaultCharset UTF-8
DirectoryIndex index.html index.htm index.php  

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.aaaa.com$ [NC]
RewriteRule ^(.*)$ http://3g.bbbb.com/tonew.html [R=301,L]
RewriteCond %{HTTP_HOST} ^aaaa.com$ [NC]
RewriteRule ^(.*)$ http://3g.bbbb.com/tonew.html [R=301,L]


RewriteCond %{REQUEST_URI} !^/cccc/.*   [NC]
RewriteCond %{HTTP_HOST} ^www.cccc.com$ [NC]
RewriteRule ^(.*)$ /cccc/ [R=301,L]


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


</IfModule>

再一个ok的htaccess

AddDefaultCharset UTF-8
DirectoryIndex index.html index.htm index.php  

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.xxxx.com$ [NC]
RewriteRule ^(.*)$ http://3g.aaaa.com/tonew.html [R=301,L]
RewriteCond %{HTTP_HOST} ^xxxx.com$ [NC]
RewriteRule ^(.*)$ http://3g.aaaa.com/tonew.html [R=301,L]



RewriteCond %{HTTP_HOST} ^www.yyyy.com$ [NC]
#RewriteRule ^$ http://www.yyyy.com/index.htm [R=301,L]
RewriteRule ^$ /index.htm [R=301,L]
RewriteCond %{HTTP_HOST} ^yyyy.com$ [NC]
RewriteRule ^$ http://www.yyyy.com/ [R=301,L]


</IfModule>

再一个ok的htaccess

#下面一行就是htacess禁止访问时跳到的页面

ErrorDocument 403 /error/noindex.html

AddDefaultCharset UTF-8
DirectoryIndex index.html index.htm index.php  

<IfModule mod_rewrite.c>

RewriteEngine On

#下面是让域名为www.mmmmm.com的 首页跳到 tonew
RewriteCond %{HTTP_HOST} ^www.mmmmm.com$ [NC]
RewriteRule ^(.*)$ http://3g.nnnnnn.com/tonew.html [R=301,L]
RewriteCond %{HTTP_HOST} ^mmmmm.com$ [NC]
RewriteRule ^(.*)$ http://3g.nnnnnn.com/tonew.html [R=301,L]


#这个是让3g.nnnnnn.com无法访问
RewriteCond %{HTTP_HOST} ^3g.nnnnnn.com$ [NC]
RewriteRule ^(?!tonew|error)[^>]*  – [F]


#下面是让域名为www.jjjjjj.com的首页跳到 index.htm
RewriteCond %{HTTP_HOST} ^www.jjjjjj.com$ [NC]
#RewriteRule ^$ http://www.jjjjjj.com/index.htm [R=301,L]
RewriteRule ^$ /index.htm [R=301,L]
RewriteCond %{HTTP_HOST} ^jjjjjj.com$ [NC]
RewriteRule ^$ http://www.jjjjjj.com/ [R=301,L]


RewriteCond % !^$  
RewriteRule uploads/(.*).(php)$ – [F]  
RewriteRule data/(.*).(php)$ – [F]  
RewriteRule templets/(.*).(php)$ – [F]
RewriteRule plus/(.*).(php)$ – [F]
RewriteRule member/(.*).(php)$ – [F]
RewriteRule special/(.*).(php)$ – [F]

#RewriteRule include/(?!vdimgck).{7}.(php)$ – [F] 效果不理想
RewriteRule include/(?!vdimgck|dialog/select_images)[^>]*.(php)$ – [F]
RewriteRule data/(.*).(php)$ – [F]
RewriteRule a/(.*).(php)$ – [F]
RewriteRule images/(.*).(php)$ – [F]

</IfModule>

 

再一个ok的htaccess

#系统有跳到错误页面

ErrorDocument 403 /error/noindex.html
AddDefaultCharset UTF-8
DirectoryIndex index.html index.htm index.php  

<IfModule mod_rewrite.c>

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

#下面这个是访问 某域名是 就让它禁止不能访问 系统有跳到错误页面
RewriteCond %{HTTP_HOST} ^www.aaa.com$ [NC]
RewriteRule ^(?!error)[^>]*  – [F]

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos" [NC]

RewriteRule ^(.*)$ http://3g.bbb.com/ [NC,R=301]

#给在线咨询做个伪静态
RewriteRule TEL:400-6363-098$ /mmm/abcd.php


RewriteCond % !^$  
RewriteRule uploads/(.*).(php)$ – [F]  
RewriteRule data/(.*).(php)$ – [F]  
RewriteRule templets/(.*).(php)$ – [F]
RewriteRule plus/(.*).(php)$ – [F]
RewriteRule member/(.*).(php)$ – [F]
RewriteRule special/(.*).(php)$ – [F]
#RewriteRule include/(?!vdimgck).{7}.(php)$ – [F] 效果不理想
RewriteRule include/(?!vdimgck|dialog/select_images)[^>]*.(php)$ – [F]
RewriteRule data/(.*).(php)$ – [F]
RewriteRule a/(.*).(php)$ – [F]
RewriteRule images/(.*).(php)$ – [F]

</IfModule>
 

再一个ok的htaccess

ErrorDocument 403 /error/noindex.html

AddDefaultCharset UTF-8
DirectoryIndex index.html index.htm index.php  

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.bbb.com$ [NC]
RewriteRule ^(.*)$ http://3g.mmmmm.com/tonew.html [R=301,L]
RewriteCond %{HTTP_HOST} ^bbb.com$ [NC]
RewriteRule ^(.*)$ http://3g.mmmmm.com/tonew.html [R=301,L]


#这个是让3g.mmmmm.com无法访问
RewriteCond %{HTTP_HOST} ^3g.mmmmm.com$ [NC]
RewriteRule ^(?!tonew|error)[^>]*  – [F]

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

RewriteCond % !^$  
RewriteRule uploads/(.*).(php)$ – [F]  
RewriteRule data/(.*).(php)$ – [F]  
RewriteRule templets/(.*).(php)$ – [F]
RewriteRule plus/(.*).(php)$ – [F]
RewriteRule member/(.*).(php)$ – [F]
RewriteRule special/(.*).(php)$ – [F]

#RewriteRule include/(?!vdimgck).{7}.(php)$ – [F] 效果不理想
RewriteRule include/(?!vdimgck|dialog/select_images)[^>]*.(php)$ – [F]
RewriteRule data/(.*).(php)$ – [F]
RewriteRule a/(.*).(php)$ – [F]
RewriteRule images/(.*).(php)$ – [F]

</IfModule>


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

普通分类: