• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to set up the htaccess File on Apache on CentOS/RHEL

by admin

The .htaccess file is a configuration file used by Apache web servers to control and override web server configuration settings on a per-directory basis.

It is a plain text file that is usually placed in the root directory of a website or in a specific directory and allows you to configure various settings for that directory, such as authentication, URL redirection, access control, error handling, and more.

To set up the .htaccess file on Apache on CentOS/RHEL, follow these steps:

1. Log in to your server via SSH as the root user or a user with sudo privileges.

2. Navigate to the Apache configuration directory by running the following command:

# cd /etc/httpd/conf/

3. Open the main Apache configuration file httpd.conf in a text editor. You can use nano or vi:

# vi httpd.conf

Look for the AllowOverride directive and change its value from None to All for the directory where you want to enable .htaccess files. For example, if you want to enable .htaccess files for the root directory of your website, you can add the following block of code to the end of the file:

<Directory /var/www/html>
    AllowOverride All
</Directory>

Save the changes and exit the editor.

4. Restart the Apache web server for the changes to take effect:

# systemctl restart httpd

Filed Under: Linux

Some more articles you might also be interested in …

  1. uuid: command not found
  2. e2fsck Command Examples in Linux
  3. zip: command not found
  4. CentOS / RHEL : How to set chroot jail for vsftp only for specific users
  5. calligrasheets: Calligra’s spreadsheet application
  6. cargo doc: Build and view Rust package documentation offline
  7. locale Command Examples in Linux
  8. diffstat: Create a histogram from the output of the diff command
  9. Linux OS Service ‘xendomains’
  10. archlinux-java Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright