Copy Code code as follows:
AuthName "Yousite Website Coming Soon ..."//If you want to give your site additional access
AuthType Basic
AuthUserFile d:/xxx/.htpasswd #如果你想设置密码访问 How to build. HTPASSWD can access 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'll allow you to create a system.php controller,
#previously This would is 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 the If the user was 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>
Source: Cnblogs Micro bo: @ grassroots Xiao Hu