Apache disable directory index

apache directory index

When Apache Directory Index is enabled, if you browse to a url that have no index file present, you will see list of all files. This is not good for securiy as hackers can see all files present in the directory. One way to disable this directory listing is create a file with name index.html … Read more

apachectl status www-browser not found

apachectl status

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: not found ‘www-browser -dump http://localhost:80/server-status’ failed. Maybe you need to install a package providing www-browser or you need to adjust the APACHE_LYNX variable in /etc/apache2/envvars root@server:~# To fix error, install lynx text based browser. apt … Read more

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] Or Redirect 301 /OLD_FOLDER /NEW_FOLDER if new folder is on another domain, you can use https://new-domain.com/OLD_FOLDER See Redirect

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 .htaccess Add following content AuthType Basic AuthName “Restricted Content” AuthUserFile /etc/apache2/site-logins Require valid-user In this case, i used /etc/apache2/site-logins as AuthUserFile, this will store all user and password. You can change this file path to … Read more

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 show actual visitor IP address, you can enable remoteip apache module. On Debian/Ubuntu server: On RHEL/CentOS/Fedora, it is Usually enabled by default; check with: Cloudflare publishes its IP ranges here: IPv4: https://www.cloudflare.com/ips-v4IPv6: https://www.cloudflare.com/ips-v6 Create file … Read more

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 the folder on HTTP. For this, i used following in .htaccess file. RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !^/auth/.* RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Here any url like yourdomain.extn/auth/ will not get redirected to HTTPS. … Read more

Apachectl

apachectl command is used to interact with Apache web server. To see Apache status apachectl status To list virtualhost info, run apachectl -t -D DUMP_VHOSTS List VirtualHost + server config. apachectl -S To list loaded apache modules, run apachectl -M Related Posts Apache Web Server apachectl status www-browser not found

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 helpfull when you have multiple web sites on same Apache web server. To install mod_ruid2 on Ubuntu/Debian server, run apt install libapache2-mod-ruid2 Edit VirtualHost entry for the web site, add RMode config RUidGid USERNAME_HERE GROUP_HERE … Read more