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 Google的translate API代码
Dec 10 PHP
Discuz 6.0+ 批量注册用户名
Sep 13 PHP
ecshop 订单确认中显示省市地址信息的方法
Mar 15 PHP
PHP人民币金额数字转中文大写的函数代码
Feb 27 PHP
使用PHP遍历文件目录与清除目录中文件的实现详解
Jun 24 PHP
PHP 函数call_user_func和call_user_func_array用法详解
Mar 02 PHP
PHP+ajaxfileupload+jcrop插件完美实现头像上传剪裁
Jun 09 PHP
php中convert_uuencode()与convert_uuencode函数用法实例
Nov 22 PHP
PHP获取数组中单列值的方法
Jun 10 PHP
解决出现SoapFault (looks like we got no XML document)的问题
Jun 24 PHP
利用laravel搭建一个迷你博客实战教程
Aug 13 PHP
php实现解析xml并生成sql语句的方法
Feb 03 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
Dedecms常用函数解析
2008/02/01 PHP
php入门学习知识点八 PHP中for循环基本应用之九九乘法口绝表
2011/07/14 PHP
PHP 登录记住密码实现思路
2013/05/07 PHP
php将字符串转化成date存入数据库的两种方式
2014/04/28 PHP
PHP中一些可以替代正则表达式函数的字符串操作函数
2014/11/17 PHP
Laravel中如何增加自定义全局函数详解
2017/05/09 PHP
jQuery.extend 函数的详细用法
2012/06/27 Javascript
jquery将一个表单序列化为一个对象的方法
2013/12/02 Javascript
JS是按值传递还是按引用传递
2015/01/30 Javascript
JavaScript多线程详解
2015/08/12 Javascript
layui 优化button按钮和弹出框的方法
2018/08/15 Javascript
在vue中更换字体,本地存储字体非引用在线字体库的方法
2018/09/28 Javascript
基于Proxy的小程序状态管理实现
2019/06/14 Javascript
用Golang运行JavaScript的实现示例
2019/11/25 Javascript
Vue学习之组件用法实例详解
2020/01/06 Javascript
[46:03]LGD vs VGJ.T 2018国际邀请赛小组赛BO2 第一场 8.16
2018/08/17 DOTA
使用Python实现windows下的抓包与解析
2018/01/15 Python
Python异常对代码运行性能的影响实例解析
2018/02/08 Python
基于Python实现定时自动给微信好友发送天气预报
2018/10/25 Python
Django框架orM与自定义SQL语句混合事务控制操作
2019/06/27 Python
keras多显卡训练方式
2020/06/10 Python
Python如何telnet到网络设备
2021/02/18 Python
HTML5 File接口在web页面上使用文件下载
2017/02/27 HTML / CSS
HMV日本官网:全球知名的音乐、DVD和电脑游戏零售巨头
2016/08/13 全球购物
车间班组长岗位职责
2013/11/13 职场文书
求职毕业生自荐书
2014/02/08 职场文书
村委会换届选举方案
2014/05/03 职场文书
高中学生自我评价范文
2014/09/23 职场文书
学院党的群众路线教育实践活动整改方案
2014/10/04 职场文书
党委工作总结2015
2015/04/27 职场文书
奠基仪式致辞
2015/07/30 职场文书
区域销售大会开幕词
2016/03/04 职场文书
研究生毕业登记表的自我鉴定范文
2019/07/15 职场文书
Python 详解通过Scrapy框架实现爬取百度新冠疫情数据流程
2021/11/11 Python
MySQL优化常用的19种有效方法(推荐!)
2022/03/17 MySQL
Python如何加载模型并查看网络
2022/07/15 Python