codeigniter 用.htcaccess做动态二级域名解析

╰+攻爆jí腚メ 2021-11-02 04:18 198阅读 0赞

今天将服务器php版本升到了5.4.4,然后将之前的一个项目改用apache,动态二级转向用.htcaccess,共享一下

  1. AuthName "yousite Website Coming Soon..." //如果你想给你的网站加个权限访问
  2. AuthType Basic
  3. AuthUserFile D:/xxx/.htpasswd #如果你想设置密码访问 如何生成.htpasswd可以访问 http://www.htaccesstools.com/htpasswd-generator/
  4. #AuthGroupFile /dev/null
  5. require valid-user
  6. <IfModule mod_rewrite.c>
  7. RewriteEngine On
  8. RewriteBase /
  9. #Removes access to the system folder by users.
  10. #Additionally this will allow you to create a System.php controller,
  11. #previously this would not have been possible.
  12. #'system' can be replaced if you have renamed your system folder.
  13. RewriteCond %{REQUEST_URI} ^system.*
  14. RewriteRule ^(.*)$ /index.php?/$1 [L]
  15. #When your application folder isn't in the system folder
  16. #This snippet prevents user access to the application folder
  17. #Submitted by: Fabdrol
  18. #Rename 'application' to your applications folder name.
  19. RewriteCond %{REQUEST_URI} ^application.*
  20. RewriteRule ^(.*)$ /index.php?/$1 [L]
  21. <IfModule mod_proxy.c>
  22. # Redirect to boutique (with any trailing path)
  23. RewriteCond %{HTTP_HOST} !^www. [NC]
  24. RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC]
  25. RewriteRule ^(.*)$ http://www.yousite.com/boutique/$1$2 [P,L]
  26. </IfModule>
  27. <IfModule !mod_proxy.c>
  28. # Redirect to boutique (with any trailing path)
  29. RewriteCond %{HTTP_HOST} !^www. [NC]
  30. RewriteCond %{HTTP_HOST} ^([^.]+).yousite.com(.*)$ [NC]
  31. RewriteRule ^(.*)$ http://www.yousite.com/boutique/%1/$1 [R=301,L]
  32. </IfModule>
  33. ## Otherwise, force www;
  34. RewriteCond %{HTTP_HOST} ^yousite.com$ [NC]
  35. RewriteRule ^(.*)$ http://www.yousite.com/$1 [R=301,L]
  36. #Checks to see if the user is attempting to access a valid file,
  37. #such as an image or css document, if this isn't true it sends the
  38. #request to index.php
  39. RewriteCond %{REQUEST_FILENAME} !-f
  40. RewriteCond %{REQUEST_FILENAME} !-d
  41. RewriteRule ^(.*)$ index.php/$1 [L]
  42. </IfModule>
  43. <IfModule !mod_rewrite.c>
  44. # If we don't have mod_rewrite installed, all 404's
  45. # can be sent to index.php, and everything works as normal.
  46. # Submitted by: ElliotHaughin
  47. ErrorDocument 404 /index.php
  48. </IfModule>

转载于:https://www.cnblogs.com/hubj/archive/2012/06/30/2571162.html

发表评论

表情:
评论列表 (有 0 条评论,198人围观)

还没有评论,来说两句吧...

相关阅读

    相关 域名

    对于域名,民间叫法和正确叫法是有出入的,建议心里有正确的概念,可以跟随周边人的叫法,只是为了沟通统一口径 URL的构成——http://主机名 . 域名(端口号、参数、查询

    相关 DNS域名

    [DNS域名解析][DNS] DNS域名解析 整个过程大体描述如下,其中前两个步骤是在本机完成的,后8个步骤涉及到真正的域名解析服务器:1、浏览器会检查缓存中有没有

    相关 DNS域名

    DNS域名解析,就是将URL地址解析成IP地址,这样才能在互联网中找到相应的主机,并建立连接,虽然我们平时上网的时候感觉不到DNS的存在,但是一旦DNS解析出错,那么对于互联网