.htaccess problem

.htaccess problem

am 29.03.2008 17:55:20 von Marshall Dudley

I don't seem to be able to get a simple RewriteCond to work. I am
wanting to prevent accesses to any files in a certain directory, except
for the index file, if referred from other than our server. Here is the
code I have

RewriteEngine On
RewriteCond %{HTTP_REFERER} !"http://www.king-cart\.com/ [NC]
RewriteRule !^.*index.html$ /error.html

The index.html file is:

this is the index file and is displaying unimpeded


The bad.html is this:

this it the file to be protected

and the error.html is this:

you are only allowed to go to this page from our site

If you go to http://www.king-cart.com/testdir/index.html it displays as
it should. But if you click on the link that presents, you get the
error.html displayed, instead of the bad.html file even though the
REFERER is http://www.king-cart.com. Anyone have any idea how to get
this simple test working so I can use it?

Thanks,

Marshall

Re: .htaccess problem

am 29.03.2008 19:10:13 von HansH

"Marshall Dudley" schreef in bericht
news:YvuHj.44014$G23.17208@newsreading01.news.tds.net...
> I don't seem to be able to get a simple RewriteCond to work. I am wanting
> to prevent accesses to any files in a certain directory, except for the
> index file, if referred from other than our server. Here is the code I
> have

> RewriteEngine On
> RewriteCond %{HTTP_REFERER} !"http://www.king-cart\.com/ [NC]
> RewriteRule !^.*index.html$ /error.html
Your condition has 2 problems:
- unbalanced quotes
- protocol should not be included

Try your luck without warranty using
RewriteEngine on
# Uncomment the next line to allow refererless access
# RewriteCond %{HTTP_REFERER} !=""
RewriteCond %{HTTP_REFERER} !king-cart\.com/ [NC]
# Return 403 'forbidden' rather then an alternate page
RewriteRule !index.html$ - [F,L]

Modifying the response code should prevent most browsers from
locally caching the alternate page. You may want to explain the
issue by presenting an errordocument.

HansH

Re: .htaccess problem

am 30.03.2008 03:32:21 von Marshall Dudley

HansH wrote:
> "Marshall Dudley" schreef in bericht
> news:YvuHj.44014$G23.17208@newsreading01.news.tds.net...
>
>> I don't seem to be able to get a simple RewriteCond to work. I am wanting
>> to prevent accesses to any files in a certain directory, except for the
>> index file, if referred from other than our server. Here is the code I
>> have
>>
>
>
>> RewriteEngine On
>> RewriteCond %{HTTP_REFERER} !"http://www.king-cart\.com/ [NC]
>> RewriteRule !^.*index.html$ /error.html
>>
> Your condition has 2 problems:
> - unbalanced quotes
> - protocol should not be included
>
> Try your luck without warranty using
> RewriteEngine on
> # Uncomment the next line to allow refererless access
> # RewriteCond %{HTTP_REFERER} !=""
> RewriteCond %{HTTP_REFERER} !king-cart\.com/ [NC]
> # Return 403 'forbidden' rather then an alternate page
> RewriteRule !index.html$ - [F,L]
>
> Modifying the response code should prevent most browsers from
> locally caching the alternate page. You may want to explain the
> issue by presenting an errordocument.
>
> HansH
>
>
>
>
Thanks. I need a new monitor!!!! The whole time I thought the quote was
a carat! I changed it to a carat which is what it was suppose to be,
and now it works. I do see the caching problem though while testing it.
I am not sure how to modify the caching code, Can that be done in the
..htaccess file, or does it need to be done in the httpd.conf file?

Thanks,

Marshall

Re: .htaccess problem

am 30.03.2008 11:13:22 von HansH

"Marshall Dudley" schreef in bericht
news:F4CHj.44020$G23.3827@newsreading01.news.tds.net...
> HansH wrote:
>> "Marshall Dudley" schreef in bericht
>> news:YvuHj.44014$G23.17208@newsreading01.news.tds.net...
>>> RewriteEngine On
>>> RewriteCond %{HTTP_REFERER} !"http://www.king-cart\.com/ [NC]
>>> RewriteRule !^.*index.html$ /error.html
>>>
>> Your condition has 2 problems:
>> - unbalanced quotes
>> - protocol should not be included
>>
>> Try your luck without warranty using
>> RewriteEngine on
>> # Uncomment the next line to allow refererless access
>> # RewriteCond %{HTTP_REFERER} !=""
>> RewriteCond %{HTTP_REFERER} !king-cart\.com/ [NC]
>> # Return 403 'forbidden' rather then an alternate page
>> RewriteRule !index.html$ - [F,L]
>>
> Thanks. I need a new monitor!!!! The whole time I thought the quote was a
> carat! I changed it to a carat which is what it was suppose to be, and
> now it works. I do see the caching problem though while testing it. I am
> not sure how to modify the caching code, Can that be done in the .htaccess
> file, or does it need to be done in the httpd.conf file?
>

Header set Cache-Control "no-cache, no-store"
Header set Pragma "no-cache, no-store"
Header set Expires "Thu, 01 Jan 1970 00:00:01 GMT"


Not allowing cache will increase bandwidth used, jus disallowing the
alternate file might do.

Drop your current code next time.

HansH

Re: .htaccess problem

am 31.03.2008 16:11:13 von Marshall Dudley

HansH wrote:
> "Marshall Dudley" schreef in bericht
> news:F4CHj.44020$G23.3827@newsreading01.news.tds.net...
>
>> HansH wrote:
>>
>>> "Marshall Dudley" schreef in bericht
>>> news:YvuHj.44014$G23.17208@newsreading01.news.tds.net...
>>>
>>>> RewriteEngine On
>>>> RewriteCond %{HTTP_REFERER} !"http://www.king-cart\.com/ [NC]
>>>> RewriteRule !^.*index.html$ /error.html
>>>>
>>>>
>>> Your condition has 2 problems:
>>> - unbalanced quotes
>>> - protocol should not be included
>>>
>>> Try your luck without warranty using
>>> RewriteEngine on
>>> # Uncomment the next line to allow refererless access
>>> # RewriteCond %{HTTP_REFERER} !=""
>>> RewriteCond %{HTTP_REFERER} !king-cart\.com/ [NC]
>>> # Return 403 'forbidden' rather then an alternate page
>>> RewriteRule !index.html$ - [F,L]
>>>
>>>
>> Thanks. I need a new monitor!!!! The whole time I thought the quote was a
>> carat! I changed it to a carat which is what it was suppose to be, and
>> now it works. I do see the caching problem though while testing it. I am
>> not sure how to modify the caching code, Can that be done in the .htaccess
>> file, or does it need to be done in the httpd.conf file?
>>
>>
>
> Header set Cache-Control "no-cache, no-store"
> Header set Pragma "no-cache, no-store"
> Header set Expires "Thu, 01 Jan 1970 00:00:01 GMT"
>

>
> Not allowing cache will increase bandwidth used, jus disallowing the
> alternate file might do.
>
> Drop your current code next time.
>
> HansH
>
>
>
Thanks, but when I add that to the .htaccess file, it gives me a server
error (misconfiguration)

Marshall