代码之家  ›  专栏  ›  技术社区  ›  greenie

.htaccess CakePHP站点上“即将到来”页面的规则

  •  1
  • greenie  · 技术社区  · 15 年前

    webroot 目录保护通过 .htpasswd 因此,只有经过授权的用户才能在网站建设期间访问该网站。但是,常客在访问时应显示“即将到来”页面 thesiteurl.com thesiteurl.com/index.html . 所有授权用户将通过访问 thesiteurl.com/index.php 并输入登录凭据。

    /.htaccess
    /comingsoon - directory containing images, css and js for the coming soon page
    /index.html - the "Coming Soon" page
    /index.php - the page authorised users use to access the site
    /webroot/.htaccess
    /webroot/index.php
    

    DirectoryIndex index.html
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !/
        RewriteCond %{REQUEST_URI} !/index\.html
        RewriteRule ^$ webroot/ [L]
        RewriteRule (.*) webroot/$1 [L]
    </IfModule>
    

    webroot/.htaccess的内容

    AuthName "Restricted Area"
    AuthType Basic
    AuthUserFile /path/to/my/.htpasswd
    AuthGroupFile /dev/null
    require valid-user
    
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>
    

    这些访问规则把我带到 绝对寻址 目录文件列表,如果我尝试访问 如果我访问的话,还有一个空白页面,样式和我网站的其他部分一样 网址:thesiteurl.com/index.html文件 网址:thesiteurl.com/index.php文件

    3 回复  |  直到 15 年前
        1
  •  3
  •   Leo    15 年前

    最简单的方法是将公共访问文件放入app/视图/页面。

    1. 设置auth(如果您 需要迟早)给予 http://book.cakephp.org/view/172/Authentication

    2. 如果你还没做,收到 将蛋糕/库/控制器放入 在PagesController中筛选之前

      function beforeFilter()
      {
          parent::beforeFilter();
          $this->Auth->allowedActions = array('display');
      }
      

      看到了吗 http://book.cakephp.org/view/854/The-Pages-Controller

    3. 蛋糕送的东西-以后只会给你带来麻烦。

        2
  •  0
  •   Chuck Burgess    15 年前

    test.thesiteurl.com
    

    然后在主url上,可以放置一个静态索引.html不需要跳过所有的障碍。这将允许那些需要访问的人能够到达他们需要的位置。那些“外看内看”的人将访问主站点并看到“即将到来”。

    我们经常尝试将开发站点与生产站点合并,就像您在这里尝试的那样。跳过所有的障碍是没有意义的。仅仅因为它可以按照你建议的方式来做,我不认为你应该这样做。K.I.S.S.永远是最好的选择。尽量简单。不要浪费你宝贵的时间去想办法做事情。尤其是当它被扔掉的时候。

        3
  •  0
  •   Bot    15 年前

    这就是问题所在。 http://yoursite.com 自动转到webroot目录。你有你的索引.html文件位于无法访问的webroot之上一级。你需要做的是以下几点。

    /webroot
        /beta - directory containing all beta site pages
            .htaccess - Contains your restricted area code
            index.php - the page authorised users use to access the site
        .htaccess
        index.html - the "Coming Soon" page
    

    当你想查看你的临时网站去 http://yoursite.com/beta