LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-16-2014, 01:48 AM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 527

Rep: Reputation: Disabled
Apache htaccess disallow adding these rules


Hello,

on a server how i can disallow anyone adding into .htaccess apache rules like:
AddType txt .php

and

AddHandler cgi-script .cin

(addtype, addhandler)?

// update: i found regarding php, it can be set that php files are handled only by apache, not txt or anything else:
this into httpd.conf or similar:
Quote:
<FilesMatch "\.ph(p[2-6]?|tml)$"> # this equal to: .php, .php2, .php3, .php4, .php5, .php6 .phtml
SetHandler application/x-httpd-php5
</FilesMatch>
but regarding cgi, im unsure

Last edited by postcd; 07-16-2014 at 09:12 AM.
 
Old 07-16-2014, 02:20 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by postcd View Post
Hello,

on a server how i can disallow anyone adding into .htaccess apache rules like:
AddType txt .php

and

AddHandler cgi-script .cin

(addtype, addhandler)?
You can use AllowOverride excluding the FileInfo keyword, e.g.
Code:
AllowOverride Options Indexes Authconfig
For more details have a look here
Regards
 
Old 07-16-2014, 09:19 AM   #3
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
thx, i thought Indexes are part of "Options" directive, the "Options" contains "FollowSymLinks" which i think i need to have allowed in .htaccess because of Joomla.

Please where can i place that lince you mentioned? into global php.ini or global httpd.conf? that line dont need to have anything around it to work?
 
Old 07-16-2014, 10:38 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Please where can i place that lince you mentioned? into global php.ini or global httpd.conf? that line dont need to have anything around it to work?
You need to put it into a <Directory /some/dir></Directory> section.
If you want to use it globally for your server replace "/some/dir" with the path to docroot
 
Old 07-16-2014, 01:56 PM   #5
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
thx, so these into global php.ini or httpd.conf?

You mentioned
Quote:
AllowOverride Options Indexes Authconfig
but i know my sites using options and indexes directives in htaccess, so i would rather disable only that Addtype, Addhandler :-/
 
Old 07-17-2014, 12:18 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
thx, so these into global php.ini or httpd.conf?
In httpd.conf. Note that php.ini has nothing to do with apache configuration


Quote:
You mentioned
AllowOverride Options Indexes Authconfig
but i know my sites using options and indexes directives in htaccess, so i would rather disable only that Addtype, Addhandler :-/
It's just an example, to show you, that if you want to disable those 2 directives, then don't use FileInfo in the AllowOverride directive
 
Old 07-18-2014, 02:15 AM   #7
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
Question

thanks, so please anyone knows how to disable addtype, addhandler "directives?" in httpd.conf ?
 
Old 07-18-2014, 03:36 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by postcd View Post
thanks, so please anyone knows how to disable addtype, addhandler "directives?" in httpd.conf ?
You can't disable them in httpd.conf. Just don't use them if you don't need them.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache disallow executing php using htaccess - how? postcd Linux - Server 1 06-25-2014 12:49 PM
Force .htaccess rules to apply to subdirectories Dareros Linux - Software 1 06-15-2014 03:59 AM
[SOLVED] [CentOS][Apache]Security of .htaccess rules thelinuxist Linux - Security 2 02-03-2014 04:13 AM
htaccess two begginer rules (I think) what they do markotitel Linux - Server 4 05-27-2013 01:08 PM
[SOLVED] Debian, Lenny, suEXEC, Apache2, .htaccess rewrite rules don't work anymore. Mogget Linux - Server 1 07-10-2010 06:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration