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.MVC的模板标签系统(二)
Sep 05 PHP
一个简单的MySQL数据浏览器
Oct 09 PHP
PHP与javascript的两种交互方式
Oct 09 PHP
非常不错的MySQL优化的8条经验
Mar 24 PHP
php 空格,换行,跳格使用说明
Dec 18 PHP
php查看请求头信息获取远程图片大小的方法分享
Dec 25 PHP
phpmyadmin打开很慢的解决方法
Apr 21 PHP
PHP表单验证内容是否为空的实现代码
Nov 14 PHP
php读取出一个文件夹及其子文件夹下所有文件的方法示例
Jun 15 PHP
PHP使用Redis实现防止大并发下二次写入的方法
Oct 09 PHP
PHP中的Iterator迭代对象属性详解
Apr 12 PHP
laravel-admin select框默认选中的方法
Oct 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
网页游戏开发入门教程二(游戏模式+系统)
2009/11/02 PHP
PHP+AJAX 投票器功能
2017/11/11 PHP
Javascript 原型和继承(Prototypes and Inheritance)
2009/04/01 Javascript
javascript 页面只自动刷新一次
2009/07/10 Javascript
jQuery实现切换页面布局使用介绍
2011/10/09 Javascript
jquery 卷帘效果实现代码(不同方向)
2013/02/05 Javascript
jquery 文本上下无缝滚动,鼠标放上去就停止 小例子
2013/06/05 Javascript
jQuery学习笔记之toArray()
2014/06/09 Javascript
Boostrap基础教程之JavaScript插件篇
2016/09/08 Javascript
node vue项目开发之前后端分离实战记录
2017/12/13 Javascript
浅谈从React渲染流程分析Diff算法
2018/09/08 Javascript
vue多级复杂列表展开/折叠及全选/分组全选实现
2018/11/05 Javascript
Element-UI中关于table表格的那些骚操作(小结)
2019/08/15 Javascript
vue中进行微博分享的实例讲解
2019/10/14 Javascript
JavaScript中的Proxy对象
2020/11/27 Javascript
JavaScript canvas实现跟随鼠标移动小球
2021/02/09 Javascript
Windows下Python使用Pandas模块操作Excel文件的教程
2016/05/31 Python
对pycharm 修改程序运行所需内存详解
2018/12/03 Python
如何使用python实现模拟鼠标点击
2020/01/06 Python
python ssh 执行shell命令的示例
2020/09/29 Python
Python实现Appium端口检测与释放的实现
2020/12/31 Python
一文带你掌握Pyecharts地理数据可视化的方法
2021/02/06 Python
简单介绍CSS3中Media Query的使用
2015/07/07 HTML / CSS
纯css实现照片墙3D效果的示例代码
2017/11/13 HTML / CSS
S’well Bottle保温杯官网:绝缘不锈钢水瓶
2018/05/09 全球购物
汽车检测与维修专业求职信
2013/10/30 职场文书
运动会通讯稿300字
2014/02/02 职场文书
广告学专业自荐信范文
2014/02/24 职场文书
公关活动策划方案
2014/05/25 职场文书
小学安全汇报材料
2014/08/14 职场文书
爱的奉献演讲稿
2014/09/10 职场文书
反四风问题学习心得体会
2016/01/22 职场文书
经销商会议开幕词
2016/03/04 职场文书
UNION CREATIVE《Re:从零开始的异世界生活》雷姆手办
2022/03/20 日漫
Nginx隐藏式跳转(浏览器URL跳转后保持不变)
2022/04/07 Servers
mysql 排序失效
2022/05/20 MySQL