User Tools

Site Tools


apache_htaccess_centos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
apache_htaccess_centos [2015/03/30 07:50] luke7858apache_htaccess_centos [2024/05/23 07:26] (current) – external edit 127.0.0.1
Line 2: Line 2:
 \\ \\
  
-.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 **/etc/httpd/conf/httpd.conf** file. The section looks similar to:+.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. 
 + 
 +You may have to uncomment the section in the **/etc/httpd/conf/httpd.conf** file. The section looks similar to:
  
 <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's 
-# default start page (in /apache2-default) when you go to / 
-#RedirectMatch ^/$ /apache2-default/ 
 </Directory> </Directory>
 </sxh> </sxh>
 +\\ 
 +=== 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), you can change this to what ever file you wish to protect. Add this section to the file: This example shows the file being used to protect the specific file that admins use to log into the wordpress site (wp-login.php), you can change this to what ever file you wish to protect. Add this section to the file:
  
Line 37: Line 38:
 </Files> </Files>
 </sxh> </sxh>
- +\\ 
 +=== Document Path Protection (authentication) === 
 +<sxh bash> 
 +<Directory "/www/docs/private"> 
 +    AuthName "Private" 
 +    AuthType Basic 
 +    AuthUserFile /var/www/html/.htpasswd 
 +    Require valid-user 
 +</Directory> 
 +</sxh>
 \\ \\
 === 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 /var/www/.htpass username 
 +</sxh>
 **Example:** **Example:**
  
apache_htaccess_centos.1427701845.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki