apache_htaccess_centos
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
apache_htaccess_centos [2015/03/30 07:41] – created luke7858 | apache_htaccess_centos [2024/05/23 07:26] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
==== htaccess for apache ==== | ==== htaccess for apache ==== | ||
+ | \\ | ||
+ | .htaccess allows for management of webserver configuration and can be used for things link: specifying protecting of a location, protecting wp-admin login for wordpress and configuring mod_rewrites. To use the .htaccess file you will need to allow the file the ability to override all. This will need to be configured in the apache config file or the vhost itself. \\ | ||
+ | If you change the apache configuration file then this will allow it for all vhosts created. If you allow the .htaccess in a vhost config file then it will only work for that specific vhost. | ||
- | .htaccess to can be used to specify protecting of a location or protect wp-admin login for wordpress. To use the .htaccess file you will need to allow the file the ability to override all. This will need to be configured in the apache config file AND the vhost itself. | + | You may have to uncomment the section in the **/ |
<sxh bash> | <sxh bash> | ||
Line 21: | Line 24: | ||
Order allow,deny | Order allow,deny | ||
allow from all | allow from all | ||
- | # Uncomment this directive is you want to see apache2' | ||
- | # default start page (in / | ||
- | # | ||
</ | </ | ||
</ | </ | ||
+ | \\ | ||
+ | === Basic http File Protection (authentication) === | ||
This example shows the file being used to protect the specific file that admins use to log into the wordpress site (wp-login.php), | This example shows the file being used to protect the specific file that admins use to log into the wordpress site (wp-login.php), | ||
Line 37: | Line 38: | ||
</ | </ | ||
</ | </ | ||
- | + | \\ | |
+ | === Document Path Protection (authentication) === | ||
+ | <sxh bash> | ||
+ | < | ||
+ | AuthName " | ||
+ | AuthType Basic | ||
+ | AuthUserFile / | ||
+ | Require valid-user | ||
+ | </ | ||
+ | </ | ||
\\ | \\ | ||
=== Mod_rewrite apache === | === Mod_rewrite apache === | ||
Line 64: | Line 74: | ||
You can use an online generator to produce the .htpasswd username and hashed password or you can do it via the command line. | You can use an online generator to produce the .htpasswd username and hashed password or you can do it via the command line. | ||
+ | == Command Line Example == | ||
+ | Change the path below to where you wish to store the password file | ||
+ | <sxh bash> | ||
+ | htpasswd -c / | ||
+ | </ | ||
**Example: | **Example: | ||
Line 73: | Line 87: | ||
webdeveloper: | webdeveloper: | ||
</ | </ | ||
- | + | ||
+ | \\ | ||
+ | === phpMyAdmin .htaccess === | ||
- | htaccess for nginx (http auth) | ||
- | |||
- | nginx does not support .htaccess, more information can be found at the following link on why it doesn’t: http:// | ||
- | |||
- | If you are lazy and you already have a .htaccess file then you can use the following link to convert that into nginx format: htaccess to nginx | ||
- | |||
- | The standard format for the htaccess would be: | ||
- | |||
- | location ^~ / | ||
- | auth_basic " | ||
- | auth_basic_user_file / | ||
- | |||
- | |||
- | |||
- | You add this code to the vhost (server block), change secret directory to the location or file you wish to protect, restart/ | ||
- | |||
- | Just incase you are still confused the following code is what I use for my website: | ||
- | |||
- | # nginx configuration | ||
- | location / | ||
- | auth_basic_user_file / | ||
- | auth_basic " | ||
- | } | ||
- | |||
- | Please note: you will still need the .htpassword file and will need to specify the location. | ||
- | |||
- | |||
- | |||
- | mod_rewrite for nginx | ||
- | |||
- | For mod_rewrite you will need the following code: | ||
- | |||
- | try_files $uri $uri/ / | ||
- | |||
- | |||
- | |||
- | phpMyAdmin .htaccess | ||
- | |||
- | CentOS | ||
To password protect phpMyAdmin you should edit / | To password protect phpMyAdmin you should edit / | ||
+ | <sxh bash> | ||
AuthType Basic | AuthType Basic | ||
AuthName "Enter account information" | AuthName "Enter account information" | ||
AuthUserFile / | AuthUserFile / | ||
Require valid-user | Require valid-user | ||
+ | </ | ||
AuthUserFile – this should reference the .htaccess password file you have set up previously | AuthUserFile – this should reference the .htaccess password file you have set up previously |
apache_htaccess_centos.1427701266.txt.gz · Last modified: 2024/05/23 07:26 (external edit)