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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. rc-update Command Examples in Linux
  2. fstrim: command not found
  3. deluser Command Examples in Linux
  4. arping: Discover and probe hosts in a network using the ARP protocol (Command Examples)
  5. ipcs Command Examples in Linux
  6. lvdisplay Command Examples in Linux
  7. trash Command Examples in Linux
  8. numlockx: command not found
  9. “Failed to start test.mount: Unit is not loaded properly: Invalid argument.” – While mounting a fileystem using systemd
  10. mandb Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright