Score:0

Issue in showing Apache ErrorDocument based on HTTP_USER_AGENT and REMOTE_ADDR

sa flag

I need to restrict access to application based on ip address and need to block displaying page if it is opened other than chrome. Now i can able to restrict ip, But if i put the browser checking option, then instead of ip address checking, browser checking error document is displaying.

RewriteEngine on
RewriteMap hosts-allow "txt:D:\conf\apache\allowlist.txt" ErrorDocument 403 "This ip is not permitted" RewriteCond "${hosts-allow:%{REMOTE_ADDR}|NOT-FOUND}" "=NOT-FOUND" [OR] RewriteCond "${hosts-allow:%{REMOTE_HOST}|NOT-FOUND}" "=NOT-FOUND" RewriteRule .* - [F]

    ErrorDocument 403 "Only Chrome and Internet Explorer are supported by this application. Your browser is not supported." 
    RewriteCond %{HTTP_USER_AGENT} "Android|Macintosh|Linux|Mobile|OPR/|Firefox/"
    RewriteRule "^/?(.*)" - [F]

Can anyone care to provide some solution for this

java_mechanic avatar
sa flag
The issue is solved by changing the rewrite rule, RewriteMap hosts-allow "txt:D:\conf\apache\allowlist.txt" ErrorDocument 405 "This ip is not permitted" RewriteCond "${hosts-allow:%{REMOTE_ADDR}|NOT-FOUND}" "=NOT-FOUND" [OR] RewriteCond "${hosts-allow:%{REMOTE_HOST}|NOT-FOUND}" "=NOT-FOUND" RewriteRule "^/?(.*)" - [L,R=405]
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.