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.
Related
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 .
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.)
Does anyone know where is the .htaccess file located after I install in linux red hat 5?
There is no .htaccess file that's installed. You will have a global config file for Apache, which is in /etc/httpd/conf/httpd.conf on RedHat (see http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/4/html/Reference_Guide/s1-apache-config.html). On the other hand, .htaccess files are something you create on a per-directory basis where the actual web files live.
I've searched for this for a while but have not been able to find a solution. How can I configure Apache to run any ELF executable in the web root as a CGI program? For example, if I write and compile a C program and place it as /var/www/something, I want to be able to visit http://localhost/something and have Apache run the program, outputting the result, instead of prompting me to download the binary.
Edit: I know how to run CGI programs, and those outside of cgi-bin, I just want to find out how to run ELF executables with no extension such as .cgi, possibly using Apache to detect the magic of the file.
How about using the files directive to whitelist your executable names?
<files something>
SetHandler cgi-script
</files>
Or better, can you put all your executables into a single known subdirectory?
<location /exec>
SetHandler cgi-script
</location>
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.