Questions tagged [.htaccess]

Directory-level configuration file found mostly on Apache web servers

The htaccess file is a supplemental configuration file used by Apache to modify the default configuration as it applies to the directory the htaccess file it in (as well as all the files and subdirectories in that directory).

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.
Source: Apache manual

The directives allowed in htaccess files are governed from the main Apache configuration files by means of the AllowOverride directive.

The most common use is in conjunction with the mod_rewrite and security modules of the Apache webserver. Mod_rewrite allows URLs to be rewritten for scenarios such as the following:

  • Shortcuts such as example.com/info to redirect to another page
  • Redirects from old pages to new pages
  • virtual directories (directories which actually appear elsewhere in the file system)

The most common security applications are:

  • Password protection of directories and files

For more information see the mod_rewrite and aaa documentation.

2807 questions
1
vote
3 answers

.htaccess and linux permissions

I have some inherited php code that I'm attempting to secure. However, removing execute permissions from the file upload directory throws a permissions error. Here's a quick rundown: apache points to /root/www/ (only user on the system is…
Ryre
  • 113
  • 1
  • 6
1
vote
1 answer

Apache Limit directive not working as expected

I want to use 'Limit' to allow GETs and POSTs, to a page requiring authentication, from only certain sites. I want authentication for GETs and POSTs from a certain IP, who should be able to access without authenticating. allow from…
MF86
  • 73
  • 1
  • 3
  • 7
1
vote
1 answer

htaccess config to block depending on browser agent

In one case i wish to block all Internet Explorer versions from my site using htaccess. I have read several guides but still can not get it to work. what is the most understanding way of doing it. If somebody can show an example and explain it for…
Luis Alvarado
  • 179
  • 1
  • 11
1
vote
1 answer

Apache Authentication w/ OS X User Accounts

Is it possible to configure Apache to use the host machine's user accounts for authentication? Say I've got Apache running on a vanilla OS X install and want to basically allow admin users to authenticate with their system username/password. Even…
Wilco
  • 365
  • 5
  • 17
1
vote
1 answer

Internet Explorer not recognizing htaccess rule

I have the following rule in my .htaccess file: RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] I want to redirect requests to the www version of my site. It doesn't work when I tried on Internet…
berto77
  • 111
  • 1
1
vote
1 answer

How can I exclude a single file from Apache mod_auth Require valid-user?

I have a testing site which has a Require valid-user directive, employing Apache's mod_auth to keep it private, but I'd like to exempt a single file from this requirement (i.e. make it so that you don't need a username / password to access that one…
balleyne
  • 11
  • 1
  • 2
1
vote
2 answers

PHP settings from php.ini in .htaccess file - possible?

Possible Duplicate: User Specific Php.ini When php is ran as a module? Hello, I need to increase some limits for PHP but do not have access to php.ini. The changes I need to make would look like this: php_value upload_max_filesize 50M php_value…
Francisc
  • 153
  • 1
  • 3
  • 11
1
vote
1 answer

Restrict certain user to access only from certain IP in apache

I need to restrict certain user from a BasicAuth configured system to come only from certain IP address but allow the rest to come from anywere. I know that I can restrict access using Deny and Allow directives and know also how to restrict access…
theist
  • 1,229
  • 2
  • 10
  • 24
1
vote
1 answer

Will 1500 URL Redirects in .htaccess affect performance?

I would like to add 1500 URL redirections using .htaccess on an Apache server. Is it a bad idea? Will it decrease the performance significantly?
mnml
  • 337
  • 1
  • 7
  • 21
1
vote
2 answers

Increase php session time via .htaccess not working

I want to create the session timeout to 6 hours but my browser is still timing out in 1/2 hour. I am on a PLESK server. I updated .htaccess php_value session.gc_maxlifetime 21600 php_value session.cache_expire 21600 php_value…
Ken
1
vote
2 answers

Weird htaccess problem and php denying internal requests

I have added Order Deny,Allow Deny from all allow from *my ip* to my htaccess file but now when I use a function like getimagesize, I get an error while trying to retrieve the data from a local file on the server. Error: [function.getimagesize]:…
John
1
vote
1 answer

.htaccess block for hostname "."

quick one for Apache gurus - how to block a hostname that is simply: . -without blocking anything else. Not sure how they managed to achieve this but it seems to be a bot that doesn't want to be identified. Latest IP is 204.45.209.208 uses various…
Rothbert
  • 11
  • 1
1
vote
1 answer

htaccess and addhandler problem

htaccess addhandler not working when changed. Main site.com - is running php4 sub.site.com - needs to run php5 i've added in the following Addhandler: AddHandler application/x-httpd-php5 .php .php4 .php3 .phtml .tpl .html AddHandler…
acctman
  • 214
  • 1
  • 5
  • 11
1
vote
2 answers

Force SSL with Name-based Virtual Host (possibly with .htaccess)

I have several subdomains served by Apache using Name-based Virtual Hosts. The way it's set up is that I have one directory holding all the site's pages, but it's accessible using several subdomains (a web application with a different theme for each…
SaltyNuts
  • 275
  • 1
  • 6
  • 12
1
vote
2 answers

Using ModRewrite to direct subdomains appropriately fails on MediaTemple

I am familiar with modifying .htaccess files but my initial attempts to do so continue to fail. Ultimately, I want to point users to 'imaginary' subdomains (those which do not exist) so that the subdomain can be parsed correctly with PHP and MySQL…
JM4
  • 1,144
  • 3
  • 18
  • 29