Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3375 > unrolled thread

.htaccess vs PHP header(location:)

Started byMichael Joel <no@please.com>
First post2011-10-10 22:40 -0400
Last post2011-10-11 06:02 -0400
Articles 7 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  .htaccess vs PHP header(location:) Michael Joel <no@please.com> - 2011-10-10 22:40 -0400
    Re: .htaccess vs PHP header(location:) Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-10 23:08 -0400
      Re: .htaccess vs PHP header(location:) Michael Joel <no@please.com> - 2011-10-10 23:33 -0400
      Re: .htaccess vs PHP header(location:) Bill B <me@privacy.net> - 2011-10-11 07:49 -0400
        Re: .htaccess vs PHP header(location:) The Natural Philosopher <tnp@invalid.invalid> - 2011-10-11 14:56 +0100
    Re: .htaccess vs PHP header(location:) The Natural Philosopher <tnp@invalid.invalid> - 2011-10-11 09:15 +0100
      Re: .htaccess vs PHP header(location:) Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-11 06:02 -0400

#3375 — .htaccess vs PHP header(location:)

FromMichael Joel <no@please.com>
Date2011-10-10 22:40 -0400
Subject.htaccess vs PHP header(location:)
Message-ID<0ja7975a0ieulqube5a6cc6fqrdqiir7nr@4ax.com>
I am wanting to control access to my site.
Sometimes I want the site "off" with visitors redirected to a folder.

I have been using htaccess but have written a php script to automate
the site's on/off control. I am considering using php at the top of
each page instead of htaccess.

basic outline:
my script creates a file when the site is to close. It contains the
reason for closing (text), close time (timestamp), and re-open time
(timestamp). (...I could also have the script create an htaccess file
if that is decided to be best...)

My thought is to, instead of use htaccess for the redirect, simple
place a PHP file_exists() check at top of every page on the site
(scripts as well). If the file exists then header (location:
xxxxxxxxx) is used to force a redirect.

The advantage to this is:
1) I had help making the htaccess file - I haven't a clue what all the
jibberish means. So changing the access to allow certain areas open or
not is not easy. I would like to find a simple PDF doc that would give
simple explanations on it.

2) it would allow a lot of control on what to close. I simple don't
include the check on pages/scripts I want to remain "open".

I did wonder if the file_exists check would cause a large slow down on
serving pages?

Thanks
Mike

[toc] | [next] | [standalone]


#3377

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-10-10 23:08 -0400
Message-ID<j70bum$d1j$1@dont-email.me>
In reply to#3375
On 10/10/2011 10:40 PM, Michael Joel wrote:
> I am wanting to control access to my site.
> Sometimes I want the site "off" with visitors redirected to a folder.
>
> I have been using htaccess but have written a php script to automate
> the site's on/off control. I am considering using php at the top of
> each page instead of htaccess.
>
> basic outline:
> my script creates a file when the site is to close. It contains the
> reason for closing (text), close time (timestamp), and re-open time
> (timestamp). (...I could also have the script create an htaccess file
> if that is decided to be best...)
>
> My thought is to, instead of use htaccess for the redirect, simple
> place a PHP file_exists() check at top of every page on the site
> (scripts as well). If the file exists then header (location:
> xxxxxxxxx) is used to force a redirect.
>
> The advantage to this is:
> 1) I had help making the htaccess file - I haven't a clue what all the
> jibberish means. So changing the access to allow certain areas open or
> not is not easy. I would like to find a simple PDF doc that would give
> simple explanations on it.
>
> 2) it would allow a lot of control on what to close. I simple don't
> include the check on pages/scripts I want to remain "open".
>
> I did wonder if the file_exists check would cause a large slow down on
> serving pages?
>
> Thanks
> Mike

No, it shouldn't require a lot of overhead to check to see if a file 
exists.  Such an option should work fine, as long as you remember to 
include it every time.

However - if you're going to be doing web work, you need to learn some 
basic things like coding some simple things in .htaccess to be 
effective.  So I would also recommend you spend a little time learning 
that.  It's not too hard once you get the hang of it.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#3380

FromMichael Joel <no@please.com>
Date2011-10-10 23:33 -0400
Message-ID<5od7975c8e9lsvk1r02rp0u8nv40s4blj5@4ax.com>
In reply to#3377
On Mon, 10 Oct 2011 23:08:03 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

>On 10/10/2011 10:40 PM, Michael Joel wrote:
>> I am wanting to control access to my site.
>> Sometimes I want the site "off" with visitors redirected to a folder.
>>
>> I have been using htaccess but have written a php script to automate
>> the site's on/off control. I am considering using php at the top of
>> each page instead of htaccess.
>>
>> basic outline:
>> my script creates a file when the site is to close. It contains the
>> reason for closing (text), close time (timestamp), and re-open time
>> (timestamp). (...I could also have the script create an htaccess file
>> if that is decided to be best...)
>>
>> My thought is to, instead of use htaccess for the redirect, simple
>> place a PHP file_exists() check at top of every page on the site
>> (scripts as well). If the file exists then header (location:
>> xxxxxxxxx) is used to force a redirect.
>>
>> The advantage to this is:
>> 1) I had help making the htaccess file - I haven't a clue what all the
>> jibberish means. So changing the access to allow certain areas open or
>> not is not easy. I would like to find a simple PDF doc that would give
>> simple explanations on it.
>>
>> 2) it would allow a lot of control on what to close. I simple don't
>> include the check on pages/scripts I want to remain "open".
>>
>> I did wonder if the file_exists check would cause a large slow down on
>> serving pages?
>>
>> Thanks
>> Mike
>
>No, it shouldn't require a lot of overhead to check to see if a file 
>exists.  Such an option should work fine, as long as you remember to 
>include it every time.
>
>However - if you're going to be doing web work, you need to learn some 
>basic things like coding some simple things in .htaccess to be 
>effective.  So I would also recommend you spend a little time learning 
>that.  It's not too hard once you get the hang of it.

Thank you for your reply.
I have apache's docs that have a few topics on it but so far it is
quite confusing. I have looked at the file and can make out what it is
doing (basically) but I don't get the punctuation marks and how they
are effecting it.

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/site_closed.*
RewriteRule ^(.*)$ http://www.parksandsonspiano.com/site_closed/ [R,L]

I get the basic idea but all the marks I am lost on. I guess I will
try to reread the doc again when I am not so tired.

Thanks again for the help
Mike

[toc] | [prev] | [next] | [standalone]


#3387

FromBill B <me@privacy.net>
Date2011-10-11 07:49 -0400
Message-ID<j71afc$bg9$1@dont-email.me>
In reply to#3377
On 10/10/2011 11:08 PM, Jerry Stuckle wrote:
> On 10/10/2011 10:40 PM, Michael Joel wrote:
>> I am wanting to control access to my site.
>> Sometimes I want the site "off" with visitors redirected to a folder.
>>
>> I have been using htaccess but have written a php script to automate
>> the site's on/off control. I am considering using php at the top of
>> each page instead of htaccess.
>>
>> basic outline:
>> my script creates a file when the site is to close. It contains the
>> reason for closing (text), close time (timestamp), and re-open time
>> (timestamp). (...I could also have the script create an htaccess file
>> if that is decided to be best...)
>>
>> My thought is to, instead of use htaccess for the redirect, simple
>> place a PHP file_exists() check at top of every page on the site
>> (scripts as well). If the file exists then header (location:
>> xxxxxxxxx) is used to force a redirect.
>>
>> The advantage to this is:
>> 1) I had help making the htaccess file - I haven't a clue what all the
>> jibberish means. So changing the access to allow certain areas open or
>> not is not easy. I would like to find a simple PDF doc that would give
>> simple explanations on it.
>>
>> 2) it would allow a lot of control on what to close. I simple don't
>> include the check on pages/scripts I want to remain "open".
>>
>> I did wonder if the file_exists check would cause a large slow down on
>> serving pages?
>>
>> Thanks
>> Mike
>
> No, it shouldn't require a lot of overhead to check to see if a file
> exists. Such an option should work fine, as long as you remember to
> include it every time.
>
> However - if you're going to be doing web work, you need to learn some
> basic things like coding some simple things in .htaccess to be
> effective. So I would also recommend you spend a little time learning
> that. It's not too hard once you get the hang of it.

Can it be as simple as setting $open_for_business to zero or one in a 
file named "can_enter.php", including the file, and allowing access to 
pages based on the value of $open_for_business?

Bill B

[toc] | [prev] | [next] | [standalone]


#3391

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2011-10-11 14:56 +0100
Message-ID<j71htp$s41$1@news.albasani.net>
In reply to#3387
Bill B wrote:
> On 10/10/2011 11:08 PM, Jerry Stuckle wrote:
>> On 10/10/2011 10:40 PM, Michael Joel wrote:
>>> I am wanting to control access to my site.
>>> Sometimes I want the site "off" with visitors redirected to a folder.
>>>
>>> I have been using htaccess but have written a php script to automate
>>> the site's on/off control. I am considering using php at the top of
>>> each page instead of htaccess.
>>>
>>> basic outline:
>>> my script creates a file when the site is to close. It contains the
>>> reason for closing (text), close time (timestamp), and re-open time
>>> (timestamp). (...I could also have the script create an htaccess file
>>> if that is decided to be best...)
>>>
>>> My thought is to, instead of use htaccess for the redirect, simple
>>> place a PHP file_exists() check at top of every page on the site
>>> (scripts as well). If the file exists then header (location:
>>> xxxxxxxxx) is used to force a redirect.
>>>
>>> The advantage to this is:
>>> 1) I had help making the htaccess file - I haven't a clue what all the
>>> jibberish means. So changing the access to allow certain areas open or
>>> not is not easy. I would like to find a simple PDF doc that would give
>>> simple explanations on it.
>>>
>>> 2) it would allow a lot of control on what to close. I simple don't
>>> include the check on pages/scripts I want to remain "open".
>>>
>>> I did wonder if the file_exists check would cause a large slow down on
>>> serving pages?
>>>
>>> Thanks
>>> Mike
>>
>> No, it shouldn't require a lot of overhead to check to see if a file
>> exists. Such an option should work fine, as long as you remember to
>> include it every time.
>>
>> However - if you're going to be doing web work, you need to learn some
>> basic things like coding some simple things in .htaccess to be
>> effective. So I would also recommend you spend a little time learning
>> that. It's not too hard once you get the hang of it.
> 
> Can it be as simple as setting $open_for_business to zero or one in a 
> file named "can_enter.php", including the file, and allowing access to 
> pages based on the value of $open_for_business?
> 
> Bill B
The way I did it for development was to recognise that my IP address is 
unique. If it finds mine, all doors are open. If not every single PHP 
script and there are nothing BUT PHP scripts and a few images and CSS 
files - has as you say an include file that says if me, return, else do 
whatever it is I decide that casual persons should be unwittingly 
exposed to, and redirect there.
.

[toc] | [prev] | [next] | [standalone]


#3381

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2011-10-11 09:15 +0100
Message-ID<j70tut$h0s$3@news.albasani.net>
In reply to#3375
Michael Joel wrote:
> I am wanting to control access to my site.
> Sometimes I want the site "off" with visitors redirected to a folder.
> 
> I have been using htaccess but have written a php script to automate
> the site's on/off control. I am considering using php at the top of
> each page instead of htaccess.
> 
> basic outline:
> my script creates a file when the site is to close. It contains the
> reason for closing (text), close time (timestamp), and re-open time
> (timestamp). (...I could also have the script create an htaccess file
> if that is decided to be best...)
> 
> My thought is to, instead of use htaccess for the redirect, simple
> place a PHP file_exists() check at top of every page on the site
> (scripts as well). If the file exists then header (location:
> xxxxxxxxx) is used to force a redirect.
> 
> The advantage to this is:
> 1) I had help making the htaccess file - I haven't a clue what all the
> jibberish means. So changing the access to allow certain areas open or
> not is not easy. I would like to find a simple PDF doc that would give
> simple explanations on it.
> 
> 2) it would allow a lot of control on what to close. I simple don't
> include the check on pages/scripts I want to remain "open".
> 
> I did wonder if the file_exists check would cause a large slow down on
> serving pages?
> 
> Thanks
> Mike
.htaccess is checked before the request gets passed to PHP.

you need a cookie setting mechanism, to place access control under PHP.

PS Jerry is not here to help: he is here to show off.

[toc] | [prev] | [next] | [standalone]


#3384

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-10-11 06:02 -0400
Message-ID<j7148j$4ac$1@dont-email.me>
In reply to#3381
On 10/11/2011 4:15 AM, The Natural Philosopher wrote:
> Michael Joel wrote:
>> I am wanting to control access to my site.
>> Sometimes I want the site "off" with visitors redirected to a folder.
>>
>> I have been using htaccess but have written a php script to automate
>> the site's on/off control. I am considering using php at the top of
>> each page instead of htaccess.
>>
>> basic outline:
>> my script creates a file when the site is to close. It contains the
>> reason for closing (text), close time (timestamp), and re-open time
>> (timestamp). (...I could also have the script create an htaccess file
>> if that is decided to be best...)
>>
>> My thought is to, instead of use htaccess for the redirect, simple
>> place a PHP file_exists() check at top of every page on the site
>> (scripts as well). If the file exists then header (location:
>> xxxxxxxxx) is used to force a redirect.
>>
>> The advantage to this is:
>> 1) I had help making the htaccess file - I haven't a clue what all the
>> jibberish means. So changing the access to allow certain areas open or
>> not is not easy. I would like to find a simple PDF doc that would give
>> simple explanations on it.
>>
>> 2) it would allow a lot of control on what to close. I simple don't
>> include the check on pages/scripts I want to remain "open".
>>
>> I did wonder if the file_exists check would cause a large slow down on
>> serving pages?
>>
>> Thanks
>> Mike
> .htaccess is checked before the request gets passed to PHP.
>
> you need a cookie setting mechanism, to place access control under PHP.
>
> PS Jerry is not here to help: he is here to show off.

He doesn't need anything as complicated as a cookie setting mechanism. 
There are many advantages to having it under the control of .htaccess - 
like controlling non-php files.

But we all know you don't understand any of this.  It's way over the 
head of an out-of-work ditch digger.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web