开发者

Can you help me write htaccess that directs others to static html and me to my Codeigniter site?

开发者 https://www.devze.com 2023-02-10 07:43 出处:网络
Here\'开发者_StackOverflow社区s the problem, I\'m doing a rewrite of a Codeigniter site that has the requisite htaccess for removing the index.php.

Here'开发者_StackOverflow社区s the problem, I'm doing a rewrite of a Codeigniter site that has the requisite htaccess for removing the index.php.

While doing the rewrite, I want to redirect visitors to a static HTML page while I do the rewrite and test. In other words, I want to access the Codeigniter site as normal but not show it to others yet.

Thanks in advance for any help.


Something like this should do the trick. It basically says: anything coming from an IP other than the one specified, load index.html.

Therefore when you load the page, you will see the rewrite take effect as it should, while everybody else will just see the index.html.

Make sure you use your public facing IP in the rule below.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REMOTE_HOST} !^1\.1\.1\.1  #your ip goes here, escape the dots!
    RewriteRule .* index.html [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

I do have a suggestion though. Try and setup a local development environment. You can change things as much as you want without afffecting your users...


This may be useful:

http://www.askapache.com/htaccess/htaccess-for-webmasters.html


I recently needed to do the same. I came to the conclusion that using a .htaccess file is very annoying especially if you have a dynamic IP. Basically what I've been doing is using an auth library I've been writing to restrict access to functions I don't want people to see and then check their role ID and redirect them to a static site.

So my role ID is 5 and a guest is 0. So all visitors would be 0 and so you could go restrict(array('5'), 'http://www.mysite.com/static.html') in your controller and perhaps use a redirect.

My library might be of use to you: https://github.com/Vheissu/WolfAuth-for-Codeigniter-2.0- there are of course many ways of doing things like this. This is how I've combated it. Hopefully this helps you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号