Directory-level configuration file found mostly on Apache web servers

learn more… | top users | synonyms (1)

4
votes
1answer
5k views

How can I remove HTTP headers with .htaccess in Apache?

I have a website that is sending out "cache-control" and "pragma" HTTP headers for PHP requests. I'm not doing that in the code, so I'm assuming it's some kind of Apache configuration, as suggested by ...
4
votes
2answers
902 views

Forwarding 80 to 443 on Nagios woes

I perhaps just need some extra insight because I don't see where I'm going wrong. I used an SSL Cert to secure our nagios server. We want to specifically require all traffic over nagios (like 2 users, ...
4
votes
2answers
4k views

Only allow GET request with htaccess?

How should I allow only GET request to access all the files and script from my server using htaccess? My web server is Apache
4
votes
3answers
995 views

htaccess vrs httpd.conf?

Is it still true that you shouldn't use htaccess files if you can use httpd.conf? The Apache site says "In general, you should never use .htaccess files unless you don't have access to the main ...
4
votes
3answers
814 views

How to block Baidu from indexing MP3 files?

Using Apache I want to prevent people from directly downloading music via url. I just want the flash player to play it. However Baidu MP3 found the files and is establishing direct downloads to my ...
4
votes
4answers
7k views

.htaccess RewriteCond for REMOTE_ADDR while behind Load Balancer?

I have a web server behind a load-balancer. I need to add a conditional redirect to my .htaccess in order to display a maintenance page whenever we take the site offline for maintenance. This part is ...
4
votes
3answers
11k views

How to create and edit .htaccess and .htpasswd locally on my computer and then upload to my site via ftp?

I'm making a website for a client, and I want to make a password protected directory. The problem is my account type only allows FTP, so is there any way to create the .htaccess and .htpasswd files ...
4
votes
1answer
2k views

force https with apache before .htpasswd

I have this in my .htaccess file RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.myweb.com/phpmyadmin$1 [R,L] AuthUserFile /var/www/myweb/.htpasswd AuthGroupFile /dev/null ...
4
votes
2answers
4k views

Precedence of RewriteRules in .htaccess file on Apache Server

I have a number of RewriteRules in my .htaccess file. However, one specific rule is only executed if I remove another specific rule, regardless of how I order the two rules. Here's the rule which ...
4
votes
4answers
6k views

.htaccess not working (mod_rewrite)

Edit: I am pretty sure my .htaccess file is NOT being executed, and the problem is NOT with my rewrite rules. I have not having any luck getting my .htaccess with mod_rewrite working. Basically all ...
4
votes
2answers
3k views

Invalid command 'AuthType', perhaps misspelled or defined by a module not included in the server configuration

I'm trying to password protect the document root and all I get is an "internal server error" page. The Apache error log shows: Invalid command 'AuthType', perhaps misspelled or defined by a module ...
4
votes
3answers
5k views

.htaccess error “not allowed here” for all for all instructions

I am using Debian Lenny and Apache 2. I changed the default .htaccess file with: AllowOverride AuthConfig But I always get the error message not allowed here when putting any instructions in the ...
4
votes
2answers
5k views

IIS Basic Authorization ala .htaccess/.htpasswd in apache

How do I implement the protection of the pages (asp.net mvc app), so when I hit the home page or any other pages within the application I get a login dialog popup in the browser I'm looking for ...
4
votes
3answers
3k views

Does is matter in what order rules are placed in htaccess?

I hope this is a simple YES or NO answer (please specify why) Q1: Does is matter in what order the rules are placed in htaccess? Since they are completely separated items: for example Q2: If yes, am ...
4
votes
4answers
4k views

How can I perform a syntax check on an .htaccess file in a shared hosting environment?

I have a build script (Perl) that modifies the .htaccess file when I deploy my applications. As a double-check, I'd like to be able to perform some sort of syntax checking on the created .htaccess ...
4
votes
4answers
7k views

.htaccess file hacked, how to prevent this in future? [closed]

The hacker added a code in .htaccess file to redirect all search engine traffic to a malware website. I am now investigating this incident and trying to find out security loop holes. My situation is ...
4
votes
1answer
6k views

Handler for (null) returned invalid result code 70007 / causing error 500?

I am getting these errors on some pages in my site (php/apache/linux/mysql vps) on intervals and can't seem to find any reproducible scenario : Handler for (null) returned invalid result code ...
4
votes
2answers
4k views

In Apache does the .htaccess file override the httpd.conf for mod_rewrites?

In my Apache httpd.conf file I have this declaration inside a VirtualHost tag. RewriteEngine On RewriteCond %{HTTP_HOST} !^www.shanestillwell.com$ [NC] RewriteRule ^(.*)$ ...
4
votes
1answer
3k views

htaccess redirect all to one file (except from localhost)

I want to redirect all traffic to a single .php gateway file, this file will do authentication and use ajax to pull the file that was requested. So I need a .htaccess with flow like this: if ...
4
votes
1answer
547 views

Why isn't htaccess following this php_value directive?

In .htaccess I've added php_value session.name "SID" This seems to have no effect, however, and no errors are thrown in error_log. Other rewrite rules in the same .htaccess file are working as ...
4
votes
1answer
78 views

.htaccess help?

First, sorry for the shocking level of no-coding-skills. So what is probably best is that I describe what I want first. I have 2 domain names, linking to one hosting package (yes, cheap-ass option, ...
4
votes
1answer
253 views

How to redirect elgantly many redirects in htaccess?

Q1. is it possible to further optimize / compact the following rules, thereby making the entire redirections faster and easier to maintain in future? There are about twenty of these domains!! you get ...
4
votes
1answer
1k views

Have .htaccess dynamically get RewriteBase

Depending on where I install my set of files, it seems like RewriteBase seems has to change accordingly if I install it in a subdirectory rather than at the www root. For my configuration files, I ...
4
votes
1answer
3k views

Error headers: ap_headers_output_filter() after putting cache header in htaccess file

Receiving error: [debug] mod_headers.c(663): headers: ap_headers_output_filter() after I included this within the htaccess file: # 6 DAYS <FilesMatch ...
3
votes
2answers
2k views

How do I prevent my swf files being hotlinked, downloaded etc

I have swf files that are embedded in a PHP page using SWFObject. These swf files are in the same directory as my PHP files. for example www.myurl.com/index.php embeds www.myurl.com/flashfile.swf, ...
3
votes
7answers
3k views

How can I find the URL of a redirect?

I'm taking over hosting of domain that simply redirects to its online booking page of a third party provider. Because the landing page is http://example.com/generic/booking.asp I'd like to know how ...
3
votes
2answers
2k views

Is there a limit for .htaccess?

Hey all. I was just wondering if there's a limit for the .htaccess file for Apache 2. I'm working on a caching plugin and thaught that it might be a good idea to use the .htaccess file to point to ...
3
votes
2answers
2k views

How to dynamically reload nginx config

I'm currently trying to setup Nginx for a domain with production, testing and development stages. Each comes with it's own partial Nginx config file with rewrites. The production and testing stages ...
3
votes
1answer
1k views

When does Apache re-read the updates to .htaccess files?

I have a hosted server. When I update .htaccess, are the updated rules immediately in effect? I understand that hosters can do what they want, and it's impossible to know without knowing the ...
3
votes
2answers
16k views

How do you redirect URLs with a query string to another host?

This htaccess snippet is supposed to redirect myhost.com/?p=1&preview=true to alt.myhost.com/?p=1&preview=true RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^myhost.com$ [NC] ...
3
votes
2answers
1k views

Apache http to https redirection [duplicate]

I'm using below .htaccess rule to redirect all http requests to https. RewriteEngine On RewriteBase / RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} And it's working ...
3
votes
2answers
2k views

Setup IIS to prompt for username/password Window instead of using a form?

On a linux box using .htaccess you can deny access to folders etc... and when the user attemps to visit that directory/file, a window pops up asking for username/password. How would you do this on ...
3
votes
2answers
9k views

What is nginx equalant for my htaccess mod_rewrite?

Previously i was using linode VPS running Apache for my CodeIgniter website. Today i installed nginx and my website landing page is coming but the other pages that is using htaccess for rewriting URL ...
3
votes
2answers
84 views

Redirect absolutely anything to new domain with .htaccess

Ok, so I'm in need a simple redirect: Redirect 301 / http://www.new.com/ Similar to that, except I want it to catch anything, such as: ...
3
votes
1answer
496 views

Adding empty .htaccess gives 403 error

When I add an empty .htaccess file to server root (touch .htaccess) I get a 403 error. The samme error appears no matter what I put in the file (I've tried specifying <LIMIT> directives etc). ...
3
votes
2answers
10k views

Convert and redirect URL in uppercase to lowercase using .htaccess

I would like redirect a URL with uppercase characters http://localhost/A/B to a lowercase version http://localhost/a/b using the .htaccess file. Using regex I can capture A and B but is it possible ...
3
votes
1answer
2k views

.htaccess not working on Cent Os 6.4

I have installed Cent Os 6.4 -Final Version and set the environment for PHP web development. My application uses the .htaccess for url rewrite & denying direct access of files. my configuration ...
3
votes
2answers
1k views

mod_rewrite remove trailing slash is causing loops

I have a site using mod_rewrite to make pretty URLs ... everywhere I read the removing the trailing slash is good for SEO and therefore I went with the rule: RewriteRule ^(.+)/$ /$1 [R=301,L] I ...
3
votes
1answer
4k views

.htaccess - redirect non www to www and retain subdomains from redirecting

So, on my main domain 'domain.com' I created several subdomains from cPanel, like 'sub1.domain.com' and 'sub2.domain.com'. Their real location on server is in 'domain.com/sub1' and 'domain.com/sub2'. ...
3
votes
3answers
3k views

How to throw a 404 error from htaccess?

Everything I find seems to be about created a custom 404 page. That is not what I am trying to do. If I want to block access to a page I can do this in htaccess: RewriteRule pattern - [F] ...
3
votes
3answers
1k views

Set MIME type of PHP generated JavaScript file

I have a dynamically created .js file by PHP. For this to work I added the following to an Apache .htaccess file: AddHandler application/x-httpd-php .js AddType application/javascript .js But the ...
3
votes
4answers
7k views

How to redirect non-www to www without hardcoding using .htaccess?

RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ...causes a perfect, non-hardcoding 301 redirect from "www to non-www", ...
3
votes
3answers
2k views

How can I upload/download or modify .htaccess files using WebDAV?

I've set up a Ubuntu server with Apache 2. Instead of FTP I'm using WebDAV upload/download files. Works great. But it is not possible to upload/download or modify .htaccess files, because the Apache ...
3
votes
3answers
66 views

What's the proper way to setup a client chosen domain name?

In my web app, I'm toying with the idea of giving my user the opportunity to select a subdomain of their choosing, so they could select something like: foobar.myapp.com where foobar is their chosen ...
3
votes
4answers
1k views

Basic Auth on DirectoryIndex Only

I am trying to configure basic auth for my index file, and only my index file. I have configured it like so: <Files index.htm> Order allow,deny Allow from all AuthType Basic ...
3
votes
3answers
1k views

Configuring htaccess/mod_rewrite to serve static files with question mark in the URL

I've just taken on hosting of an ancient site that was converted from asp to static html, consisting of about 6,000 files. However, my server doesn't like the filenames, giving a 404 error. The URLs ...
3
votes
4answers
2k views

Different Expires Header for Specific URL

The whole application has a global expires header set in the .htaccess I have a URL e.g. /current which I need like a different expiry header.
3
votes
2answers
1k views

Configure session length with htaccess

My home web server is running the stock OSX Apache 2 install. I have some directories with content that I want to secure, so I setup htaccess files for those areas. However, I find it annoying to ...
3
votes
2answers
4k views

RewriteRules not stopping with LAST flag?

I seem to be having trouble with Apache 2.2's Rewrite module (running on FreeBSD 8). My .htaccess file is as follows: Options -Indexes RewriteEngine on RewriteRule ^xpaste$ cross.php [L] ...
3
votes
1answer
2k views

How to block PROPFIND (or any other method) on Apache

How can I block PROPFIND (or other methods, such as PUT or DELETE) on my whole site with Apache?