当前位置: 移动技术网 > IT编程>开发语言>PHP > apache+codeigniter 通过.htcaccess做动态二级域名解析

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

2019年04月17日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网