This question already has answers here:
Apache .htaccess <Directory not allowed here
(3 answers)
Closed 1 year ago.
On my localhost i use the php build in server, and want to block some directory.
<Directory /config/>
Options +Indexes
IndexOptions +FancyIndexing
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
But on my debian apache2 server i ve get an internal server error. Apache2 error log:
[Tue Dec 21 08:38:31.577748 2021] [core:alert] [pid 30883] [client xxx:42012] /var/www/html/.htaccess: <Directory not allowed here
Inside apache2.conf i use
<Directory /var/www/html/config/>
Options +Indexes
IndexOptions +FancyIndexing
Order deny,allow
Deny from all
Allow from 127.0.0.1
Related
I'm trying to configure httpd on fedora, but my two day effort has gotten me nowhere.
I installed httpd and php, added the configuration file for the site, everything is fine. I try to load it and see "access denied." but I have already granted to the apache user and apache group 755 rights (on every folder along the path).
Errors in apache log:
[Mon Jun 06 20:25:18.088420 2022] [negotiation:error] [pid 12656:tid
12758] (13)Permission denied: [client 127.0.0.1:45920] AH00686: cannot
read directory for multi: /home/concasse_master/Desktop/sample/public/
[Mon Jun 06 20:25:18.089421 2022] [proxy_fcgi:error] [pid 12656:tid
12758] [client 127.0.0.1:45920] AH01071: Got error 'Unable to open
primary script: /home/concasse_master/Desktop/sample/public/index.php
(Permission denied)'
localhost.conf:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot /home/concasse_master/Desktop/sample/public
ErrorLog logs/error.log
CustomLog logs/access.log combined
<Directory /home/concasse_master/Desktop/sample/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I am setting up Fail2ban on our server. The apache.auth jail fails as unauthorized requests are not being logged in Apache logs. I have changed the log levels, set separate access and error logs for SSL, but to no avail. Only Http 403 are getting logged in error logs. what should I do so that I can see more error details like 401 in logs.
Tried changing the log levels and
configured separate log files for ssl and normal apache logs
default-ssl in Sites- (Enabled, Available)
ErrorLog ${APACHE_LOG_DIR}/ssl_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel error
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
#Alias /doc/ "/usr/share/doc/"
#<Directory "/usr/share/doc/">
# Options Indexes MultiViews FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
#</Directory>
When I try to reach a forbidden page. Other than this, no errors logged in error log.
[Thu Sep 12 15:00:53.276750 2019] [core:crit] [pid 50926] (13)Permission denied: [client 172.16.0.44:57549] AH00529: /var/www/html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/html/' is executable
[Thu Sep 12 15:02:17.713433 2019] [core:crit] [pid 50924] (13)Permission denied: [client 172.16.0.44:57569] AH00529: /var/www/html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/html/' is executable
No matter how much I tried to get url rewrite to work, it just keep failing and I have google searched alot and try alot of codes even here on stackoverflow and none of them worked for me and at the end of the day, am forced to ask for help.
I want, like, for example, when a user click on a link, I want the users' to be shown a pretty format of the website URL in the browser in the manner or structure in the manner of that of facebook, stackoverflow, wikipedia etc are doing like when a user visit localhost:jokes=edit?4, it formats it to jokes/edit/4 or something like that.
First thing I did was to setup Virtual host and the virtualhost I setup is this
#Directory structure
<Directory C:/alls>
AllowOverride All
Require all granted
</Directory>
#this is the default address of XAMPP
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/alls/ijdb/public"
ServerName ijdb.localhost
SetEnv NS_ENV variable_value
</VirtualHost>
And in the httpd.conf, I turned all
AllowOverride
to
all
and in the hosts file add this
127.0.0.1 ijdb.localhost
Then, create this in .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !d
RewriteRule ^.*$ index.php [NC,L,QSA]
Yet, when I click on any other link apart from the home link, it returns object not found.
My question is how can I solve it?
I use XAMPP3.2.2 which comes by default with apache 2.2.34
From the error log, this is what I saw there. I don't know if it has something to do with it anyway...
[Tue Sep 11 02:07:31.554559 2018] [ssl:warn] [pid 1012:tid 376] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Tue Sep 11 02:07:32.123856 2018] [ssl:warn] [pid 1012:tid 376] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Tue Sep 11 02:07:32.239860 2018] [mpm_winnt:notice] [pid 1012:tid 376] AH00354: Child: Starting 150 worker threads.
First make sure that rewrite_module is enabled or not. Go to apache bin and load modules list like cd c:\xampp\apache\bin && apache2.exe -M
Then modify your virtualhost as below:
<VirtualHost *:80>
DocumentRoot "C:/alls/ijdb/public"
ServerName ijdb.localhost
SetEnv NS_ENV variable_value
<Directory "C:/alls/ijdb/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Check c:\xampp\apache\logs\error.log file for more detail.
Upgraded to OS X Yosemite and now my virtualhosts are spitting out the PHP file contents instead of executing the file.
This works correctly:
http://localhost
This spits out the file contents onto the screen:
http://localhost/~MYUSERNAME
<?php phpinfo();
http://testing.dev spits out the
<?php and the contents of this file (which is WordPress)
apachectl -t
Syntax OK
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
<VirtualHost *:80>
ServerName testing.dev
ServerAlias www.testing.dev
DocumentRoot "/Users/*/Sites/testing"
ErrorLog "/private/var/log/apache2/testing.dev-error_log"
<Directory "/Users/*/Sites/testing-env/">
Options Indexes FollowSymLinks
AllowOverride AlL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 testing.dev
Why is it spitting out the PHP file instead of executing it?
running php -v gives me
PHP 5.5.3 (cli) (built: Aug 28 2013 13:28:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.2, Copyright (c) 2002-2013, by Derick Rethans
error log shows:
[Mon Nov 17 17:30:08.338143 2014] [auth_digest:notice] [pid 3633] AH01757: generating secret for digest authentication ...
[Mon Nov 17 17:30:08.339341 2014] [mpm_prefork:notice] [pid 3633] AH00163: Apache/2.4.9 (Unix) PHP/5.5.14 configured -- resuming normal operations
[Mon Nov 17 17:30:08.339391 2014] [core:notice] [pid 3633] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
Upgrading OS X restores the Apache configuration files to their defaults. You’ll need to edit them again. From memory, this includes:
un-commenting the PHP handler so Apache executes files rather than serving them
Setting AllowOverride to All for your web root directory
un-commenting the line that loads the VirtualHosts configuration file
I had the same issue and found there was a missing configuration section in my httpd.conf. After adding the following and restarting Apache PHP files were processed correctly.
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
I am facing this error when deploy my laravel website on server centos 7
.htaccess: Options not allowed here
[Sat Oct 18 09:38:43.336180 2014] [core:alert] [pid 13593] [client 182.186.240.3:7034] /home/test/public_html/.htaccess: Options not allowed here
[Sat Oct 18 09:38:43.727177 2014] [core:alert] [pid 13589] [client 182.186.240.3:7123] /home/test/public_html/.htaccess: Options not allowed here
You need to provide this line in <Directory...> section of Apache config and restart Apache server in order to use Options directives in .htaccess:
Options All
As per Apache docs:
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.