apache+codeigniter 通过.htcaccess做动态二级域名解析


Posted in PHP onJuly 01, 2012
AuthName "yousite Website Coming Soon..." //如果你想给你的网站加个权限访问 
AuthType Basic 
AuthUserFile D:/xxx/.htpasswd #如果你想设置密码访问 如何生成.htpasswd可以访问 http://www.htaccesstools.com/htpasswd-generator/ 
#AuthGroupFile /dev/null 
require valid-user <IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#'system' can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
#When your application folder isn't in the system folder 
#This snippet prevents user access to the application folder 
#Submitted by: Fabdrol 
#Rename 'application' to your applications folder name. 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

<IfModule mod_proxy.c> 
# Redirect to boutique (with any trailing path) 
RewriteCond %{HTTP_HOST} !^www. [NC] 
RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC] 
RewriteRule ^(.*)$ http://www.yousite.com/boutique/$1$2 [P,L] 
</IfModule> 
<IfModule !mod_proxy.c> 
# Redirect to boutique (with any trailing path) 
RewriteCond %{HTTP_HOST} !^www. [NC] 
RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC] 
RewriteRule ^(.*)$ http://www.yousite.com/boutique/%1/$1 [R=301,L] 
</IfModule> 
## Otherwise, force www; 
RewriteCond %{HTTP_HOST} ^yousite.com$ [NC] 
RewriteRule ^(.*)$ http://www.yousite.com/$1 [R=301,L] 
#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn't true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 
<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 
ErrorDocument 404 /index.php 
</IfModule>

出处:cnblogs 微博:@草根小胡
PHP 相关文章推荐
PHP系统流量分析的程序
Oct 09 PHP
php对gzip文件或者字符串解压实例参考
Jul 25 PHP
连接到txt文本的超链接,不直接打开而是点击后下载的处理方法
Jul 01 PHP
使用php发送有附件的电子邮件-(PHPMailer使用的实例分析)
Apr 26 PHP
PHP实现自动对图片进行滚动显示的方法
Mar 12 PHP
PHP+shell实现多线程的方法
Jul 01 PHP
在WordPress的后台中添加顶级菜单和子菜单的函数详解
Jan 11 PHP
crontab无法执行php的解决方法
Jan 25 PHP
PHP实现对图片的反色处理功能【测试可用】
Feb 01 PHP
php-fpm.conf配置文件中文说明详解及重要参数说明
Oct 10 PHP
PHP面向对象程序设计之多态性的应用示例
Dec 19 PHP
Laravel框架中集成MongoDB和使用详解
Oct 17 PHP
php下载文件的代码示例
Jun 29 #PHP
PHP sprintf() 函数的应用(定义和用法)
Jun 29 #PHP
php 对输入信息的进行安全过滤的函数代码
Jun 29 #PHP
PHP删除数组中的特定元素的代码
Jun 28 #PHP
PHP安全性漫谈
Jun 28 #PHP
PHP连接SQLSERVER 注意事项(附dll文件下载)
Jun 28 #PHP
深入了解 register_globals (附register_globals=off 网站打不开的解决方法)
Jun 27 #PHP
You might like
一步一步学习PHP(6) 面向对象
2010/02/16 PHP
基于php上传图片重命名的6种解决方法的详细介绍
2013/04/28 PHP
ajax+php控制所有后台函数调用
2015/07/15 PHP
PHP的swoole扩展安装方法详细教程
2016/05/18 PHP
PHP实现的函数重载功能示例
2018/08/03 PHP
Centos7安装swoole扩展操作示例
2020/03/26 PHP
js变量作用域及可访问性的探讨
2006/11/23 Javascript
js 页面关闭前的出现提示的实现代码
2011/05/25 Javascript
js 限制数字 js限制输入实现代码
2012/12/04 Javascript
javascript改变position值实现菜单滚动至顶部后固定
2013/01/18 Javascript
Javascript拓展String方法小结
2013/07/08 Javascript
JS 如何获取radio选中后的值及不选择取radio的值
2013/10/28 Javascript
JS/Jquery判断对象为空的方法
2015/06/11 Javascript
浅谈VUE单页应用首屏加载速度优化方案
2018/08/28 Javascript
纯js+css实现在线时钟
2020/08/18 Javascript
微信小程序实现点击页面出现文字
2020/09/21 Javascript
在Python中使用模块的教程
2015/04/27 Python
Python 实现简单的shell sed替换功能(实例讲解)
2017/09/29 Python
浅谈Python 敏感词过滤的实现
2019/08/15 Python
解决Python对齐文本字符串问题
2019/08/28 Python
Python3.7基于hashlib和Crypto实现加签验签功能(实例代码)
2019/12/04 Python
python中uuid模块实例浅析
2020/12/29 Python
计算机开发个人求职信范文
2013/09/26 职场文书
如何写一份好的自荐信
2014/01/02 职场文书
保洁公司服务承诺书
2014/05/28 职场文书
医院安全生产月活动总结
2014/07/05 职场文书
售后客服个人自我评价
2014/09/14 职场文书
顶岗实习计划书
2015/01/16 职场文书
2015年宣传部工作总结范文
2015/03/31 职场文书
仙境之桥观后感
2015/06/16 职场文书
小学五年级(说明文3篇)
2019/08/13 职场文书
图解排序算法之希尔排序Java实现
2021/06/26 Java/Android
openstack中的rpc远程调用的方法
2021/07/09 Python
关于MySQL临时表为什么可以重名的问题
2022/03/22 MySQL
微信小程序APP的生命周期及页面的生命周期
2022/04/19 Javascript
Nginx 502 bad gateway错误解决的九种方案及原因
2022/08/14 Servers