Forum Moderators: phranque

Message Too Old, No Replies

I have the drama again. My .htaccess file stopped working again

.htaccess, blocking, notepad vs other text editors

         

Michel Samuel

5:34 pm on May 19, 2007 (gmt 0)

10+ Year Member



I made 1 change and that was to attempt blocking out the Alexa toolbar users.

My file stopped working...

I removed the change and I must of messed something else up too. Because it still won't work.

Forgive me I'm a photographer not a technical genious....

Can someone tell me what I'm doing wrong because I can't see my fault.

Does all of this have to be on 1 line or something like that? I one time had a problem with notepad making my file stop working. Is it similar in this case?

Thank you in advance.


#RemoveHandler .html .htm
AddHandler application/x-httpd-php .php .html .htm
<Files 403.shtml>
order allow,deny
deny from 209.200.29.36
deny from 64.255.175.11
allow from all
Options +FollowSymlinks All -Indexes
RewriteEngine on #RewriteCond %{HTTP_USER_AGENT} ^Alexa\ Toolbar [NC,OR] #RewriteCond %{HTTP_REFERER} alexa\.com [NC,OR]RewriteCond %{HTTP_REFERER} archive\.org [NC]RewriteRule .* - [F]

g1smd

6:10 pm on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That should be:

Options +FollowSymlinks All -Indexes
RewriteEngine on
#RewriteCond %{HTTP_USER_AGENT} ^Alexa\ Toolbar [NC,OR]
#RewriteCond %{HTTP_REFERER} alexa\.com [NC,OR]
RewriteCond %{HTTP_REFERER} archive\.org [NC]
RewriteRule .* - [F]

jdMorgan

6:48 pm on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the posted code, the <Files 403.shtml> container is opened, but never closed with </Files>.

Besides, you must *allow* everybody to access your custom 403 page, otherwise you will get a cascade of errors, because a denied access will result in a request for 403.shtml, which will then be denied, leading to another request for 403.shtml, which will then be denied, etc., etc.

My best guess at what you're trying to achieve:


AddHandler application/x-httpd-php .php .html .htm
Order Deny,Allow
Deny from 209.200.29.36
Deny from 64.255.175.11
<Files 403.shtml>
Allow from all
</Files>
Options All -Indexes
RewriteEngine on
RewriteCond %{REQUEST_URI} !/403\.shtml$
RewriteCond %{HTTP_USER_AGENT} ^Alexa\ Toolbar [NC,OR]
RewriteCond %{HTTP_REFERER} alexa\.com [NC,OR]
RewriteCond %{HTTP_REFERER} archive\.org [NC]
RewriteRule .* - [F]

Jim

Michel Samuel

8:21 pm on May 19, 2007 (gmt 0)

10+ Year Member



Thank you both for the aide.
JD you are truely the master of the apache serveur.

Michel Samuel

8:33 pm on May 19, 2007 (gmt 0)

10+ Year Member



I wrote too soon. I now have a 500 server error.

It must be the format of my file.
I am putting everything on 1 line. Is this a wrong thing to do?

jdMorgan

8:37 pm on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I am putting everything on 1 line. Is this a wrong thing to do?

Yes, it is absolutely the wrong thing to do.

One line, one directive or comment. No more.

Put it on your server exactly as shown above.

Jim

Michel Samuel

9:34 pm on May 19, 2007 (gmt 0)

10+ Year Member



I have been doing this for 4 hours and it is working.
But I have been reading the apache books.

I am confused on this single line or multiple line rule.

I get the book saying it is supposed to be on a single line. Then the next chapter it gives me examples on multiple lines.

jdMorgan

2:06 pm on May 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One directive must be on a single line.

If you split one directive across multiple lines, it will fail.

If you put multiple directives on a single line, it will fail.

The correct format is shown above.

Jim

Michel Samuel

4:09 pm on May 20, 2007 (gmt 0)

10+ Year Member



You explain better than the 2 chapters I read.