如何在apache中利用.htcaccess文件做动态二级域名解析-mile米乐体育

本篇文章为大家展示了如何在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 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] # 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] # 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] ## 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] # 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

上述内容就是如何在apache中利用.htcaccess文件做动态二级域名解析,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注恰卡编程网行业资讯频道。

展开全文
内容来源于互联网和用户投稿,文章中一旦含有米乐app官网登录的联系方式务必识别真假,本站仅做信息展示不承担任何相关责任,如有侵权或涉及法律问题请联系米乐app官网登录删除

最新文章

网站地图