: Disallow all user agents except one using .htaccess? I've been struggling to get this .htaccess working. The aim is to disallow all user agents besides my app. The app sends a GET request with
I've been struggling to get this .htaccess working. The aim is to disallow all user agents besides my app. The app sends a GET request with a user agent of lets say 'AcmeUpdater'.
Whenever I try to navigate to any file in the folder, I get a 500 - Internal Server Error.
Here are the rules I'm using:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} !^KMUpdaterClient*
RewriteRule .* - [F,L]
</IfModule>
I have updated the .htaccess file as suggested in the answer by Nick, and restarted Apache. After trying a couple of different things, it seems that just the presence of a .htaccess is causing the 500 error. I'm getting nothing in the error logs.
The .htaccess file at the document root looks like the following:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
So I realised that the error logs were in chronological order rather than the reverse chronological I expected (Oops!).
The error I'm getting is: </IfModule> without matching <IfModule> section. I removed the </IfModule> and still I get that error. Ideas?
More posts by @Kristi941
1 Comments
Sorted by latest first Latest Oldest Best
Finally realised what the problem was when, after deleting the tag in both files, the error "Invalid command 'xefxbbxbf
EF BB BF = BOM
Moral of the story: Always check your encoding* and hex dump of your files when you get weird issues.
*On Notepad++ you can use the Encoding -> Encode in UTF-8 without BOM option to remove it
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.