apache+codeigniter 通過.htcaccess做動態(tài)二級域名解析
更新時間:2012年07月01日 18:23:43 作者:
今天將服務(wù)器php版本升到了5.4.4,然后將之前的一個項目改用apache,動態(tài)二級轉(zhuǎn)向用.htcaccess實(shí)現(xiàn)了動態(tài)二級域名解析,共享一下
復(fù)制代碼 代碼如下:
AuthName "yousite Website Coming Soon..." //如果你想給你的網(wǎng)站加個權(quán)限訪問
AuthType Basic
AuthUserFile D:/xxx/.htpasswd #如果你想設(shè)置密碼訪問 如何生成.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)地址轉(zhuǎn)換
- CI(CodeIgniter)框架中的增刪改查操作
- 在CODEIGNITER中 在CI中引入外部的JS與CSS呢
- Codeigniter(CI)框架分頁函數(shù)及相關(guān)知識
- CI(CodeIgniter)框架介紹
- CI(CodeIgniter)框架配置
- CodeIgniter模板引擎使用實(shí)例
- php之CodeIgniter學(xué)習(xí)筆記
- Codeigniter框架的更新事務(wù)(transaction)BUG及解決方法
- Codeigniter注冊登錄代碼示例
- 解析CodeIgniter自定義配置文件
- 基于Codeigniter框架實(shí)現(xiàn)的student信息系統(tǒng)站點(diǎn)動態(tài)發(fā)布功能詳解
相關(guān)文章
PHP管理依賴(dependency)關(guān)系工具 Composer的自動加載(autoload)
Composer 是PHP的一個包依賴管理工具,類似Ruby中的RubyGems或者Node中的NPM,它并非官方,但現(xiàn)在已經(jīng)非常流行。此文并不介紹如何使用Composer,而是關(guān)注于它的autoload的內(nèi)容吧。2014-08-08
php導(dǎo)入大量數(shù)據(jù)到mysql性能優(yōu)化技巧
這篇文章主要介紹了php導(dǎo)入大量數(shù)據(jù)到mysql性能優(yōu)化技巧,通過針對SQL語句的優(yōu)化實(shí)現(xiàn)了mysql性能的提高,非常具有實(shí)用價值,需要的朋友可以參考下2014-12-12
解決php-fpm.service not found問題的辦法
這篇文章主要給大家介紹了解決php-fpm.service not found問題的辦法,文中詳細(xì)介紹的解決這個問題的思路與過程,分享出來給大家,如果有同樣問題的朋友就不用到處找解決辦法了,下面來一起看看吧。2017-06-06
thinkphp5實(shí)用入門進(jìn)階知識點(diǎn)和各種常用功能代碼匯總
這篇文章主要介紹了thinkphp5實(shí)用入門進(jìn)階知識點(diǎn)和各種常用功能代碼匯總的相關(guān)資料,需要的朋友可以參考下2023-03-03
在WAMP環(huán)境下搭建ZendDebugger php調(diào)試工具的方法
一直以來,寫php都是用Dreamweaver,有時候真是痛苦啊,出現(xiàn)一個bug,想看一些元素的值,必須用echo輸出來才知道,現(xiàn)在了解到一個斷點(diǎn)調(diào)試?yán)?,php終于也能像java、.NET那樣斷點(diǎn)調(diào)試,這就是——ZendDebugger2011-07-07
thinkphp在低版本Nginx 下支持PATHINFO的方法分享
本文給大家分享的是如何讓thinkPHP在低版本的Nginx下支持PATHINFO去掉index.php路徑的方法,十分的簡單實(shí)用,思路也很巧妙,有需要的小伙伴可以參考下2016-05-05

