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

2015-01-24信息快讯网

今天将服务器php版本升到了5.4.4,然后将之前的一个项目改用apache,动态二级转向用.htcaccess实现了动态二级域名解析,共享一下

 
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 微博:@草根小胡
解析smarty 截取字符串函数 truncate的用法介绍
完美解决令人抓狂的zend studio 7代码提示(content Assist)速度慢的问题
解析php中die(),exit(),return的区别
解析CodeIgniter自定义配置文件
php class中public,private,protected的区别以及实例分析
解析:通过php socket并借助telnet实现简单的聊天程序
浅析is_writable的php实现
解析mysql left( right ) join使用on与where筛选的差异
浅析php header 跳转
解析php中heredoc的使用方法
解析posix与perl标准的正则表达式区别
CodeIgniter图像处理类的深入解析
php之CodeIgniter学习笔记
解析CI即CodeIgniter框架在Nginx下的重写规则
浅谈apache和nginx的rewrite的区别
php.ini-dist 和 php.ini-recommended 的区别介绍(方便开发与安全的朋友)
php下载文件的代码示例
PHP连接SQLSERVER 注意事项(附dll文件下载)
深入了解 register_globals (附register_globals=off 网站打不开的解决方法)
php中jQuery插件autocomplate的简单使用笔记
header中Content-Disposition的作用与使用方法
PHP Parse Error: syntax error, unexpected $end 错误的解决办法
php提示Call-time pass-by-reference has been deprecated in的解决方法[已测]
PHP中return 和 exit 、break和contiue 区别与用法
修改PHP的memory_limit限制的方法分享
Uncaught exception com_exception with message Failed to create COM object
PHP写UltraEdit插件脚本实现方法
php XMLWriter类的简单示例代码(RSS输出)
php中关于codeigniter的xmlrpc的类在进行数据交换时的类型问题
Can't create/write to file 'C:\WINDOWS\TEMP\...MYSQL报错解决方法
php设计模式 Composite (组合模式)
php file_put_contents()功能函数(集成了fopen、fwrite、fclose)
©2014-2024 dbsqp.com