Auto index showing directories only - apache

If I add Options +Indexes in .htaccess this will display all files and subdirectories. However, I would like to exclude files for the current directory. i.e. display directories only for the current directory and display files and directories for any subdirectories.
Is this possible in .htaccess or will I need to write my own script to generate the directory index?

According to the comment of CBroe above, I've maked this approach tested in debian apache2 in .htaccess:
Options +Indexes
IndexIgnore *.*
This will ignore files with a file extension such as file.html. As we usually not name a directoty with a dot extension, so directories will be shown.
Please consult also apache autoindex reference http://httpd.apache.org/docs/2.4/mod/mod_autoindex.html .

Related

wamp3: directory listing is 404 in win 10

I installed wamp3 64 bit with php 5.6.16 and Apache 2.4.17 and MySql 5.7.9 in windows 10.
My problem:
When in a folder (in www folder) not exist index.php (OR index.html) error 404 Occurs and didn't show directories and files list.
My httpd.conf file: http://paste.ubuntu.com/14475697/
Error screenshot:
Try the following,
Create a .htaccess file and put the following directive
Options Indexes
Follow the link,
http://www.cyberciti.biz/faq/enabling-apache-file-directory-indexing/

Apache .so and .c files

I see what there is checks for mod_rewrite.c file in different .htaccess files, but i have only mod_rewrite.so, what is the difference between them?
<IfModule mod_rewrite.c>
# Make sure directory listing is disabled
Options +FollowSymLinks +Indexes
RewriteEngine on
</IfModule>
It sounds kind of backwards but that's just the way it works. The <IfModule> container wants either a module name or a module file. In the case of the module file, it wants the source file (.c). This is because some modules are compiled into apache so there is no shared library file (.so).
In the case of LoadModule, which loads a module that is external to the main apache core, you use the .so file.

Is Apache wildcard Include directive recursive?

According to Apache manual, the Include directive is recursive when a directory path is used. But is it recursive when using a wildcard path?
Include "/usr/local/apache/conf/userdata/std/2/username/domain.com/*.conf"
I checked it and it is not recursive.
As Joyce already said, I can confirm by testing it myself that it is not recursive.
Include uses fnmatch as wildcard engine, which doesn't match a slash by default, unless the FNM_PATHNAME flag is set, so a * doesn't match / so domain.com/*.conf will not look in sub-directories.
However, since httpd 2.3.6 it is possible to also use the wildcard for sub-directories.
Examples
Include /usr/local/apache2/conf.d/ssl.conf
This matches only a specific file.
Include /usr/local/apache2/conf.d
If conf.d is a file, it matches only this file. If conf.d is a directory, all files will be matched recursively, including files in sub-directories and non-conf files (which causes an error).
Include /usr/local/apache2/conf.d/*.conf
This will only match the files with a .conf suffix, directly located in the conf.d directory. Files in sub-directories aren't matches.
Include /usr/local/apache2/conf.d/*/*.conf
This will only match the files with a .conf suffix, directly located in sub-directories of the conf.d directory, but it will NOT match files directly located in the conf.d directory.
So for example, if you need to match all .conf files directly located in conf.d and in first level of sub-directories and second level of sub-directories, you can use this:
Include /usr/local/apache2/conf.d/*.conf
Include /usr/local/apache2/conf.d/*/*.conf
Include /usr/local/apache2/conf.d/*/*/*.conf
If you only have valid configuration files in conf.d and want to match every level of subdirectories, then you can use:
Include /usr/local/apache2/conf.d
Instead of using wildcard, you should use a directory.
It has been supported since as early as 1.3 https://httpd.apache.org/docs/1.3/mod/core.html#include
New in Apache 1.3.13 is the feature that if Include points to a directory, rather than a file, Apache will read all files in that directory, and any subdirectory, and parse those as configuration files.

Set PATH for Apache on per-directory basis?

How to set PATH for Apache server on a per-directory basis?
Problem: I have a system in which I can not change the
system installed python in /usr/bin/.
I have a bunch of python cgi scripts that all have
#!/usr/bin/env python
as their first line. I strongly prefer not to change
these scripts for logistical reasons.
But these scripts require a different version of Python
than the system installed one. I have the right version
installed in /opt/python/bin/. So if I could put this
directory at the front of PATH, but only for this particular
cgi directory, it would solve my problem.
That is, if the following would work, it would do what I want.
ScriptAlias /mydir/cgi/ /home/me/devel/cgi/
<Directory /home/me/devel/cgi>
SetEnv PATH /opt/python/bin:/usr/bin:/bin
...other stuff...
</Directory>
But it seems SetEnv does not work on PATH (at least on Apache 2.2).
Is there some other way to changing PATH for just one
particular directory in Apache?
(P.S., I also tried SetEnvIf without any joy.)

What can change the include_path between php.ini and a PHP file

I've inherited some code on a system that I didn't setup, and I'm running into a problem tracking down where the PHP include path is being set.
I have a php.ini file with the following include_path
include_path = ".:/usr/local/lib/php"
I have a PHP file in the webroot named test.php with the following phpinfo call
<?php
phpinfo();
When I take a look at the the phpinfo call, the local values for the include_path is being overridden
Local Value Master Value
include_path .;C:\Program Files\Apache Software Foundation\ .:/usr/local/lib/php
Apache2.2\pdc_forecasting\classes
Additionally, the php.ini files indicates no additional .ini files are being loaded
Configuration File (php.ini) Path /usr/local/lib
Loaded Configuration File /usr/local/lib/php.ini
Scan this dir for additional .ini files (none)
additional .ini files parsed (none)
So, my question is, what else in a standard PHP system (include some PEAR libraries) could be overriding the include_path between php.ini and actual php code being interpreted/executed.
Outisde of the PHP ways
ini_set( 'include_path', 'new/path' );
// or
set_include_path( 'new/path' );
Which could be loaded in a PHP file via auto_prepend_file, an .htaccess file can do do it as well
phpvalue include_path new/path
There are several reasons why you are getting there weird results.
include_path overridden somewhere in your php code. Check your code whether it contains set_include_path() call. With this function you can customise include path. If you want to retain current path just concatenate string . PATH_SEPARATOR . get_include_path()
include_path overridden in .htaccess file. Check if there are any php_value or php_flag directives adding dodgy paths
non-standard configuration file in php interpreter. It is very unlikely, however possible, that your php process has been started with custom php.ini file passed. Check your web server setup and/or php distribution to see what is the expected location of php.ini. Maybe you are looking at wrong one.
An .htaccess file or Apache's configuration (httpd.conf) could also be responsible.
Check for anything that looks like the following:
php_value include_path something
More information about that behavior here:
PHP: How to change configuration settings
The other option would be the use of ini_set() or set_include_path() somewhere, but considering that your test.php only contains phpinfo() (and assuming that test.php is called directly), I doubt that is your problem.