burger
infomaniak
infomaniak
cloud-computing-logo
Cloud Computing
web-domain-logo
Web & Domains
event-marketing-logo
Events & Marketing
  • Our products
    • Collaborative tools icon chevron
    • Web & Domains icon chevron
    • Cloud Computing icon chevron
    • Events & Marketing icon chevron
    • Streaming icon chevron

      ksuiteCollaborative suite

      Discover the collaborative suite → Discover →
    • kSuite Professional email, sovereign cloud and AI for sustainable performance
    • kSuite The suite for secure communication, storage and sharing
    • kdrive
      kDrive Store, collaborate and share your files
    • mail service
      Mail Service Create your email addresses with your domain
    • kChat
      kChat Communicate live with your teams
    • kmeet
      kMeet Organise your meetings online in complete security
    • swisstransfer
      SwissTransfer Send your files up to 50 GB free of charge.
    • kpaste
      kPaste Share and encrypt your sensitive information
    • ksuite
      Custom Brand Control the brand image of your products
    • kChat
      Chk Link reducer & QR code generator
      Find the web hosting solution you need
    • Domain name
      Domain name Reserve your domain name at the best price
    • Site Creator
      Site Creator Create your website with ease
    • web hosting
      Web Hosting Create your website with over 100 CMS
    • web hosting
      Wordpress Hosting Create your WordPress website easily
    • Cloud Server
      Cloud Server Power up your sites with guaranteed resources
    • SSL Certificat
      SSL certificates Secure your websites with an EV or DV certificate
    • Options
    • Domain privacy
      Domain Privacy Protect your domains’ private data
    • DNS Fast Anycast
      FastAnycast DNS Speed up your site access times
    • Dyn DNS
      DynDNS Access your devices remotely
    • Dyn DNS
      Renewal Warranty Secure your domains against loss and theft
      Find the right Cloud Computing solution

      Cloud services

    • public cloud
      Public Cloud (IaaS) Create your projects in a high-end, ultra-competitive Cloud
    • Cloud Server
      VPS Cloud Create a Windows / Linux server
    • Kubernetes service Deploy your containerised apps on a large scale.
    • VPS Lite
      VPS Lite Create a Windows/Linux server at a low cost
    • Database Service Manage your databases with a managed solution
    • jelastic cloud
      Jelastic Cloud (PaaS) Create your own customised environments
    • Other services

    • llm api
      AI Tools Boost your productivity with our sovereign AI
    • swiss backup
      Swiss Backup Back up your devices in the Cloud
    • nas synology
      NAS Synology Rent a NAS in our secure data centers
    • High availibility
      Very High Availability Create a multi-data center infrastructure with customised SLAs
    • Housing
      Housing Install your servers in our data centers
    • Auth Add a privacy-friendly login method to your apps
      Infomaniak Events, the independent local events portal
      Online ticketing service with a wide choice of concerts, shows and events.
    • online shop
      Ticketing Create your ticketing service and sell tickets
    • kdrive
      Access Control Control access to your events with ease
    • kdrive
      Guest manager Automate your event invitations
    • kdrive
      Newsletter Send your newsletters at competitive prices
    • Streaming radio
      Streaming radio Create and broadcast your own live radio station online
    • streaming video
      Video-Streaming Create and broadcast live events and TV online
    • VOD and AOD
      VOD & AOD service Host and broadcast your recordings without limits
  • Resources
    documentation icon Documentation
    Guides & tutorials
    API documentation
    special offers icon Special offers
    Get started for free
    Student programme
    Become an affiliate
    partner program icon Partner programme
    Find a partner
    Become a partner
    support icon Support & contact
    Contact Support
    Premium support - 24/7
    Contact our sales department
    Hiring an expert
    Migrate to Infomaniak
  • About us
    forest
    icon Ecological commitment
    We pollute. But we are taking action to reduce the footprint of our services and infrastructure
    Discover our commitment →
    icon About Infomaniak
    Our vision, our values
    Our teams
    Infomaniak is recruiting
    Press and communication
    Blog and news
    icon Security
    Data confidentiality
    Bug Bounty Programme
  • Get started for free
    Sign in
  • search-icon
    close-icon
      icon

      Would your needs exceed our solutions? To find out, contact us so that we can advise you personally.

      Our flagship products:
  • search-icon
  • Get started for free
    Sign in
Price Price
Knowledge base

1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!

Knowledge base Secure Web access via .htaccess rules

    Secure Web access via .htaccess rules

    This guide explains how to block access to certain directories of a Web Hosting for certain visitors / robots / crawlers by filtering and blocking their IP addresses or hostnames.

     

    Implement .htaccess rules

    Create a document .htaccess at the root of your site and enter the rules intended to block certain IP addresses or bots.

     

    To block visitors based on, for example, the beginning of their IP address, use the directive "deny from":

    Order Deny,Allow
    Deny from 123.456.
    Allow from all

    This means that all requests from an IP address starting with "123.456." will be denied, while all other requests will be allowed. Blocked users will receive an HTTP 403 Forbidden error message.

    Block a specific IP address

    Order Allow,Deny
    Deny from 123.456.789
    Allow from all

    This means that only one IP address, 123.456.789, is blocked and all other IP addresses can access the site.

    Blocking multiple IP addresses

    Order Allow,Deny
    Deny from 123.456.789
    Deny from 987.654.321
    Allow from all

    This means that two IP addresses, 123.456.789 and 987.654.321, are blocked and all other IP addresses can access the site.

    Block a bot by its user-agent

    SetEnvIfNoCase User-Agent "BadBot" BadBot
    Order Allow,Deny
    Deny from env=BadBot
    Allow from all

    This means that any bot identified with a user-agent "BadBot" will be blocked and all other users can access the site.

    Block access to a specific folder

    Order Allow,Deny
    Deny from all

    This means that all access to the folder "/folder" will be blocked, regardless of the IP address or user-agent. A similar assistant is available on your Infomaniak Manager.

     

    mod_rewrite directives

    You can also use the mod_rewrite directive to block certain IP addresses or bots in a .htaccess file.

     
    The directive mod_rewrite can affect the performance of your website in case of excessive or incorrect use. It is therefore recommended to be cautious when modifying your file .htaccess.

    Here are some examples:

    Block a specific IP address

    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} ^123\.456\.789\.
    RewriteRule ^(.*)$ - [F,L]

    This means that only one IP address, 123.456.789, is blocked and all other IP addresses can access the site.

    Block several IP addresses

    RewriteEngine on
    RewriteCond %{REMOTE_ADDR} ^123\.456\.789\. [OR]
    RewriteCond %{REMOTE_ADDR} ^987\.654\.321\.
    RewriteRule ^(.*)$ - [F,L]

    This means that two IP addresses, 123.456.789 and 987.654.321, are blocked and all other IP addresses can access the site.

    Block a bot by its user-agent

    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} BadBot [NC]
    RewriteRule ^(.*)$ - [F,L]

    This means that any bot identified with a user-agent "BadBot" will be blocked and all other users can access the site. This can be useful to prevent unwanted robots from accessing certain pages or consuming resources unnecessarily.

    Block access to a specific folder

    RewriteEngine on
    RewriteRule ^dossier/secret - [F,L]

    This means that all access to the folder "/dossier/secret" will be blocked, regardless of the IP address or user-agent.

    Block and redirect elsewhere

    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} ^123\.456\.789\.
    RewriteRule ^(.*)$ http://www.domain.xyz/blocked.html [L,R=301]

    This means that all requests from the IP address 123.456.789 will be redirected to the page "blocked.html" on the site "www.domain.xyz". The last part of the line RewriteRule, [L,R=301] indicates that the redirection is permanent (R=301) and that this is the last rule to be applied (L).

    You can add multiple conditions RewriteCond to block different IP addresses and redirect to different pages.

    Also, refer to this other guide.



    Link to this FAQ:
    Has this FAQ been helpful?
    Thank you for your feedback. Improve this FAQ?
    Please do not ask any questions through this form, it is only used to improve our FAQ.
    Please use our contact form for any question.
    Your message has been sent. Thank you for suggesting an improvement to this FAQ.
    Display all FAQs for this product
    logo infomaniak
    Prices do not include VAT
    facebook
    twitter
    linkedin
    instagram

    Infomaniak

    About Infomaniak The team Infomaniak is recruiting Press space Infomaniak blog All certificates Products and offers Clients' opinions

    Support

    Assistance 7/7 FAQ and guides Premium Support Sales contact API REST Report abuse WHOIS

    Partnerships

    Become a reseller Affiliate programme Directory of partners Requests for quotes

    Ecology

    Green hosting Certificates & awards

    Follow our development

    The email entered is invalid
    earth icon
    • EN
      • EN
      • DE
      • ES
      • FR
      • IT
    ©2025 Infomaniak - Legal documents - Legal notice - Data Protection - Privacy Policy - Site map - Manage your cookies
    icann-logo
    swiss
    new-iso
    swiss-hosting
    logo infomaniak
    Prices do not include VAT

    Infomaniak

    About Infomaniak The team Infomaniak is recruiting Press and media Infomaniak blog All certificates Products and offers Clients' opinions

    Support

    Assistance 7/7 FAQ and guides Premium Support offer Sales contact API REST Report abuse WHOIS

    Partnerships

    Become a reseller Affiliate programme Directory of partners Requests for quotes

    Ecology

    Green hosting Certificates & awards

    Follow our development

    The email entered is invalid
    icann-logo
    swiss
    new-iso
    swiss-hosting

    facebook
    twitter
    linkedin
    instagram
    ©2025 Infomaniak
    Contracts - Legal notice - Data Protection - Privacy Policy - Site map - Manage your cookies

    Managers

    earth icon
    • EN
      • EN
      • DE
      • ES
      • FR
      • IT
    Your browser is outdated, security and browsability are no longer guaranteed. We recommend that you update it as soon as possible by clicking here.