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

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

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 微博:@草根小胡

相关文章

thinkphp5使用bootstrapvalidator进行异步验证邮箱的示例

本文介绍了thinkphp5使用bootstrapvalidator进行异步验证邮箱的示例,分享给大家,具体如下: js验证 /** * Created by HONGXIN o...

thinkphp jquery实现图片上传和预览效果

thinkphp jquery实现图片上传和预览效果

先上效果图: 那个file按钮样式先忽略 点击选择图片(浏览),随便选一张图片 js代码如下 //上传图片立即预览 function PreviewImage(imgFil...

php带密码功能并下载远程文件保存本地指定目录 修改加强版

php带密码功能并下载远程文件保存本地指定目录 修改加强版

原作者BlueStyle 提示 改进地方有 以前的算法是等文件下载完才计算, 现在这个直接在在获取文件时候就计算大小 加了容错语句 增加了判断目录,没有目录自动创建 把计算文件大小的算法...

PHP 加密解密内部算法

将它们打包成一个文件就叫fun.php吧 复制代码 代码如下: <?php function passport_encrypt($txt, $key) { srand((doubl...

PHP实现提取一个图像文件并在浏览器上显示的代码

去年做过一个项目,要把用户上传的图像文件列出文字清单,当用户点击一个文件名后,就可以显示这个图像. 因为要考虑兼容各种不同的图像格式, 我使用了GD库, 判断出具体是那种图像文件(MIN...