<FilesMatch> in apache 2.4 - apache

I am using apache 2.4 and I want to create a link on my website to download a picture.
According to what I have found on Google, I have to put the following lines :
<FilesMatch "\.(jpg)$">
Header set Content-Disposition attachment
</FilesMatch>
But I dont know in which file I have to put this, because what I have found is about .htaccess and httpd.conf files, but those dont exist on Apache 2.4.
Thank you

Option 1: Create a new DOCUMENT_ROOT/.htaccess file and put this code there.
Option 2: Otherwise place this code in your Apache config and restart your Apache server

Related

XAMPP managing headers (server response headers)

I need to modify my localhost page server response (edit headers) - I'm using XAMPP (apache + msql, on linux machine). I can't find how to do that. Maybe some of the programmers/admins know how I can make it happened - share their knowledge and save me time.
If there is any article/link I would use it gladly.
I cannot use live server (my page is a total mess - it working on localhost by miracle...), and the only thing I have installed is xampp, so editing response headers through xampp would be perfect.
Thanks for any directions.
EDIT:
https://www.a2hosting.com/kb/developer-corner/apache-web-server/modifying-http-headers
is not working for me.
<IfModule mod_headers.c>
Header set Test "testing"
</IfModule>
inside of .htaccess
In you .htaccess file (witch should be placed where your index.html is) type:
### add custom header to all server responses from ALL files:
Header add Custom-Header: "parameter=value"
### add custom header to SINGLE file:
<Files someOtherFile.html>
Header add Custom-Header: "parameter=value"
</Files>
I'm using linux, maybe on windows there is something more you should do but remember to restart xampp after editing .htaccess.

Can't remove index.php without 404 error

I'm using Joomla 2.5 and Apache and I have followed this steps:
1- mod_rewrite module is eneabled? YES
2- htaccess.txt renamed to .htaccess
3- set "Use URL Rewriting" to YES.
And this is what I get:
Not Found
The requested URL /about-us was not found on this server.
The web is located in /var/www/
The .htaccess is located in /var/www/
And this is my .htaccess: http://pastebin.com/dq1TYs1t
Thanks for the help.
Since you said allowoverride was set to none, your .htaccess file will be ignored. You need to set allowoverride to all the other option is leave allowoverride at none, and take the contents of the .htaccess file and incorporate it into your apache configuration file. This has the benefit of being slightly faster as apache doesn't need to look in directory tree for .htaccess files (they are really good to allow users that don't have access to the configs the ability to override the base settings, but if you have access to /var/www you should also have access to make changes to the config files.
There is no need to enable any mod_rewrite module.
Need to enable URL rewriting option in global configuration. Also need to rename htaccess.txt file to .htaccess.
please check there is no any third party component of security like admin tools are enable or installed which is blocking this mod rewrite option.

.htaccess forctype not working on godaddy anymore possible rewrite rule?

My website will no longer execute an extensionless url as php anymore. I had the following in my .htaccess file which was working fine until today.
<Files pages>
ForceType x-httpd-php5-cgi
</Files>
This causes http://www.mydomain.com/pages/1/Home to run as pages/ as though it was pages.php.
Godaddy is not giving much support at this time other than indicating that they have or are updating from Apache 2.2 to 2.4.
Is it possible to do what i was doing with a rewrite rule?
Add the following lines to your .htaccess file:
Options +ExecCGI
AddHandler x-httpd-php5-3 .php
This should allow the ForceType to work properly!
F.Y.I: I had the exact same issue, so I called GoDaddy tech support, and surprisingly they were able to solve the problem. It did in fact have to do with the switch to Apache 2.4 and some changes in GoDaddy's servers.
Good Luck!
Edit:
I forgot to mention that a php5.ini file that sets cgi.fix_pathinfo = 1 is necessary!
If you are getting a "No input file specified" error, this should solve it.

Clean URL's not working, mod_rewrite module installed

I just installed a fresh copy of Drupal 6.19 to get to speed on how to write modules. But for some reason the rewrite module isn't working for Drupal.
What I have checked:
$ apachectl -M >> it is installed
php_info() on current server >> says rewrite is installed also
I also double-checked the .htaccess file in my Drupal root folder
UPDATE: checked httpd.conf for AllowOverride All
I'm out options here. Looked everywhere but the Drupal settings aren't letting me to enable the settings and their test is simply visiting a site that should work if the rewrite module was there.
My specs:
Mac OS X 10.6 Snow Leopard
Using built-in Apache with PHP5
Thanks!
Last but not least, you must authorize your virtual host or directory to use .htaccess.
AllowOverride All
Update:
I can't figure out your exact problem but it's always worth testing that Apache is actually parsing your .htaccess file. Make a syntax error on purpose and see if you get a 500 Internal Server Error message. Also, test mod_rewrite with a simple redirection rule that doesn't involve Drupal.
Two more things to check:
Verify that your .htaccess is readable for your apache processes (Yes, I read that you double checked it, but did that include the file permissions?)
Enable rewrite logging - this might give you some hints on where it fails. Start with a log level of 5 and increase/decrease as needed. (Don't forget to turn it off again later, as it is a huge performance hog ;)
Also, I'd try to simplify the test scenario - start with a simple rewrite directive in a vhost configuration. Once that works, move it to a .htaccess in the top-level of the vhosts document root, then to sub directories (if needed/used).
Make sure that if the install is in a sub-directory that the username is part of the rewriteBase
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /~username/drupal**
If you running your Drupal installation in a sub-folder like: example.com/drupal, then enable "RewriteBase /" in your .htaccess file, it might help you.
A clean url could be something like www.example.com/fisherman instead of www.example.com/data/pages/fisherman.php
Some installations of apache have clean URL functionality out of the box. There are 2 steps that need to be configured correctly for it to work.
Enable rewrite module
Allow .htaccess file overrides
Both steps require SSH root access to your server. So if you are on shared host this probably won't work for you. Open your terminal:
Enable rewrite module
To enable the rewrite module, you can type the following command
sudo a2enmod rewrite
Now type
sudo service apache2 restart
to enable the changes. You can check if it’s working by typing
sudo apache2ctl –M
A list will appear. Look for “rewrite_module”.
http://codeontrack.com/enable-clean-urls-apache/
Look for this Line in your httpd.conf file
#LoadModule rewrite_module modules/mod_rewrite.so
If commented
Just uncomment it restart apache server then try enabling in drupal administer Clean URL Section
I added the following to my .htaccess file and it was solved. My problem was specifically hapening with Rackspace / CentOS image
Options -MultiViews
As Álvaro G. Vicario mentioned, the first thing to do is at the top of the .htaccess file add something like ghfdiddfdjf which should throw an internal error. If it doesn't, you know the .htaccess file isn't being read. Mine wasn't, and I found the following fix:
In the etc/apache2/sites-enabled folder, there was a file called default-000. It was in this file that I changed AllowOverride All in 2 places in the file.

identify Apache config directive

My website has a file: www.mydomain.com/contact.php
If I request any of the following (which do not exist), apache serves the contact.php page.
www.mydomain.com/contact
www.mydomain.com/contact/
www.mydomain.com/contact/anything/else/here
How can I determine what part of the apache config to change to disallow this?
The apache server is running on a CentOS 5 box if that makes any difference.
This is called MultiViews.
A .htaccess file or modifying your httpd.conf with Options -MultiViews should do the trick.