![apache directory index](https://serverok.in/wp-content/uploads/2020/09/apache-directory-index.png)
Apache disable directory index
When Apache Directory Index is enabled, if you browse to a url that have no index file present, you will
![Enable CORS in Apache](https://serverok.in/wp-content/themes/understrap-child/images/default.webp)
Enable CORS in Apache
To enable CORS in apache, add the following in VirtualHost or .htaccess Header always set Access-Control-Allow-Origin “*” Header always set
![apachectl status](https://serverok.in/wp-content/uploads/2020/07/apachectl-status-lunx-280x180.png)
apachectl status www-browser not found
On a Ubuntu server, run i run apachectl status, i get following error. root@server:~# apachectl status /usr/sbin/apachectl: 113: /usr/sbin/apachectl: www-browser:
![Apache LogFormat show full domain name](https://serverok.in/wp-content/themes/understrap-child/images/default.webp)
Apache LogFormat show full domain name
To show the full domain name in the Apache access log, you can use the following log format LogFormat “%h
![Redirect a folder to another](https://serverok.in/wp-content/themes/understrap-child/images/default.webp)
Redirect a folder to another
To redirect a folder to another using .htaccess, create RedirectMatch 301 ^/OLD_FOLDER/(.*)$ /NEW_FOLDER/$1 Or RewriteEngine On RewriteRule ^OLD_FOLDER/(.*)$ /NEW_FOLDER/$1 [R=301,NC,L]
![Password Protect Site using htaccess](https://serverok.in/wp-content/themes/understrap-child/images/default.webp)
Password Protect Site using htaccess
To password protect a web site or a sub folder using .htaccess, create a .htaccess file in the folder. vi
![](https://serverok.in/wp-content/uploads/2020/03/cloudflare-280x180.jpg)
Apache Show Real IP Address when using CloudFlare
When using Apache web server behind cloudflare, apache logs show cloudflare IP address instead of real visitor IP address. To
![Redirect site to HTTPS excluding a folder](https://serverok.in/wp-content/themes/understrap-child/images/default.webp)
Redirect site to HTTPS excluding a folder
On a web site, customer need to redirect all pages to HTTPS, but want to keep files in one of
![](https://serverok.in/wp-content/uploads/2019/09/apache-http-webserver-280x180.png)
Apache Performance Tuning
To optimize Apache web server, run curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | sudo perl
![](https://serverok.in/wp-content/uploads/2019/09/apache-http-webserver-280x180.png)
Apache Show Real IP Behind Reverse Proxy on CentOS
When Apache web server running behind reverse proxy or load balancer, server log and scripts show IP of reverse proxy
![](https://serverok.in/wp-content/uploads/2019/09/apache-http-webserver-280x180.png)
Apachectl
apachectl command is used to interact with Apache web server. To see Apache status apachectl status To list virtualhost info,
![Apache run web site as user with mod_ruid2](https://serverok.in/wp-content/themes/understrap-child/images/default.webp)
Apache run web site as user with mod_ruid2
mod ruid2 allow you to run web site as differnt user from the one web server is running. This is