apache+codeigniter 通過.htcaccess做動態(tài)二級域名解析
更新時間:2012年07月01日 18:23:43 作者:
今天將服務器php版本升到了5.4.4,然后將之前的一個項目改用apache,動態(tài)二級轉向用.htcaccess實現(xiàn)了動態(tài)二級域名解析,共享一下
復制代碼 代碼如下:
AuthName "yousite Website Coming Soon..." //如果你想給你的網(wǎng)站加個權限訪問
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 微博:@草根小胡
您可能感興趣的文章:
- CI框架給視圖添加動態(tài)數(shù)據(jù)
- Cisco 路由器動態(tài)和靜態(tài)地址轉換
- CI(CodeIgniter)框架中的增刪改查操作
- 在CODEIGNITER中 在CI中引入外部的JS與CSS呢
- Codeigniter(CI)框架分頁函數(shù)及相關知識
- CI(CodeIgniter)框架介紹
- CI(CodeIgniter)框架配置
- CodeIgniter模板引擎使用實例
- php之CodeIgniter學習筆記
- Codeigniter框架的更新事務(transaction)BUG及解決方法
- Codeigniter注冊登錄代碼示例
- 解析CodeIgniter自定義配置文件
- 基于Codeigniter框架實現(xiàn)的student信息系統(tǒng)站點動態(tài)發(fā)布功能詳解
相關文章
mysql4.1以上版本連接時出現(xiàn)Client does not support authentication prot
mysql4.1以上版本連接時出現(xiàn)Client does not support authentication protocol問題解決辦法...2007-03-03PHP中運用jQuery的Ajax跨域調用實現(xiàn)代碼
PHP中運用jQuery的Ajax跨域調用實現(xiàn)代碼,需要的朋友可以參考下2012-02-02