Questions tagged [.htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
83 votes
4 answers
202k views

How to get Apache2 to redirect to a subdirectory

I am running apache2 on Debian etch, with multiple virtual hosts. I want to redirect so that http://git.example.com goes to http://git.example.com/git/ Should be really simple, but Google isn't ...
Hamish Downer's user avatar
61 votes
4 answers
131k views

How to redirect root and only root via htaccess?

I want to redirect only my root to another url, but maintain all the /sub/directories where they belong (and redirect) example: mysite.com/1 redirects to somewhere mysite.com/admin opens a page i ...
user avatar
40 votes
2 answers
46k views

How do I get Apache2 to parse (without error) Header directives in a .htaccess?

I am getting pages loading with a 500 internal server error, due I believe to a directive that Apache has not been configured to allow. I have AllowOverride set to all, and a .htaccess file, ...
Christos Hayward's user avatar
34 votes
1 answer
94k views

What is the name and location of the Nginx config file (htaccess equivalent)?

There are many tutorials on how to write Nginx rewrite rules to mimic Apache's .htaccess file but I can't confidently say I know what the name or location of this so-called Nginx config file actually ...
tim peterson's user avatar
30 votes
5 answers
97k views

.htaccess is ignored even though VirtualHost has "AllowOverride All"

I'm running a LAMP server on Fedora 13 that's working fine; however, I just added an ".htaccess" file to my current site's docroot folder that is being completely ignored. I've tried half a dozen ...
Brian Lacy's user avatar
  • 1,123
23 votes
2 answers
71k views

How should I use the <If> directive in .htaccess?

I'm trying to add a conditional statement using Apache's If directive in my .htaccess file. I have referenced this page http://httpd.apache.org/docs/trunk/mod/core.html#if but it doesn't elaborate ...
cwd's user avatar
  • 2,793
22 votes
3 answers
58k views

How to enable either Gzip or Deflate compression via .htaccess?

How to enable either Gzip or Deflate compression via .htaccess and which one is best these days? Code examples needed.
dzhi's user avatar
  • 830
20 votes
1 answer
32k 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 ...
Daniel Magliola's user avatar
20 votes
3 answers
853 views

Suspicious .htaccess File

This was uploaded to one of my FTP folders. I'm not familiar with Apache, but still curious - can someone tell me what type of dastardly act this file is trying to commit? Thanks! RewriteEngine On ...
ovinophile's user avatar
19 votes
2 answers
8k views

Break up a long line in a .htaccess file

I am setting a Content-Security-Policy header in my .htaccess file, and it has grown to be an extremely long single line, which is a bother to manage. Is there some way to break up this line into more ...
MaxPRafferty's user avatar
17 votes
1 answer
56k views

Apache .htaccess <ifModule not allowed here

Running Apache on Ubuntu Precise, with PHP 5.5 Trying to access my var/www/ gives me a 500. /var/log/apache2/error.log shows: /var/www/web/.htaccess: <IfModule> not allowed here my .htaccess ...
Kiksy's user avatar
  • 327
17 votes
4 answers
36k views

How to echo out from .htaccess?

We write a lot of code to htaccess but what is the best method to debug other than refreshing the page ? Is there some way that I can write it out to a file ? or is there some echo/print function ? ...
Devrim's user avatar
  • 1,187
15 votes
6 answers
2k views

to www or not to www [duplicate]

Possible Duplicate: What’s the point in having "www" in a URL? Should I use www in front of a URL or not? Some sites say we should and some say the opposite. Pros Cons If there is no www ...
user avatar
15 votes
4 answers
59k views

IIS7: How to block access with a web.config file?

I know that IIS7 allows me to have a per directory configuration with the web.config xml file. I have a directory with some configuration files that don't want to be web accessible. A local web.config ...
neves's user avatar
  • 1,270
14 votes
4 answers
4k views

Load time impact of htaccess

There are in general two possibilities of handling stuff on Apache: make configurations for folders one by one using htaccess file to fully resign htaccess and put all the rules into the httpd.conf ...
Evgeniy's user avatar
  • 255
13 votes
3 answers
8k views

How can I redirect an entire site to a single page?

I'm in the process of shutting down a site, and have replaced the old site with a single "nobody home" page at the root level of the site. Now I need to set up some redirection, so that any ...
Jim Miller's user avatar
13 votes
5 answers
25k views

Does it matter in which order rules are placed in htaccess?

I hope this is a simple YES or NO answer (please specify why) Q1: Does it matter in which order rules are placed in htaccess? Especially when they are completely separated items. Q2: If yes, am I ...
Sam's user avatar
  • 423
13 votes
1 answer
29k views

Either all Options must start with + or -, or no Option may [closed]

I have this line in a .htaccess file Options +SymLinksIfOwnerMatch ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch ExecCGI Includes ...
d0001's user avatar
  • 329
13 votes
2 answers
31k views

Configuring favicon with expires header in htaccess

I have implemented Expires headers via mod_expires on my Apache server and have successfully created expires headers for most file types, however I am having trouble with the favicon. I initially ...
user avatar
13 votes
4 answers
23k 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 ...
Jake Wilson's user avatar
  • 8,934
12 votes
1 answer
61k views

What is the difference between HTTP_HOST and HTTPS_HOST in apache .htaccess files?

I'm editing an .htaccess file.. In RewriteCondition for RewriteRules, HTTPS_HOST seems to only match urls that are accessed via https:// protocol (ssl). I saw in docs somewhere that it's a T/F ...
SherylHohman's user avatar
12 votes
3 answers
51k views

Convert and redirect URL in uppercase to lowercase using .htaccess

I would like to 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 ...
tintin's user avatar
  • 445
12 votes
5 answers
28k views

How to solve "ExpiresActive not allowed here" error message in .htaccess file?

I am trying to add Expires headers to the HTTP responses of the site I am working on. The only way for me to control the Apache 1.3 server is by editing my .htaccess file. I tried adding code such as ...
Daan's user avatar
  • 223
12 votes
2 answers
7k views

SSL redirect on EC2 instance behind SSL terminating load balancer

I'm trying to redirect all url's to https in a web application. I have an ec2 instance behind an elastic load balancer. SSL is terminated on the load balancer. Any attempts at redirection end up ...
rix's user avatar
  • 277
12 votes
1 answer
16k views

max length of url 257 characters for mod_rewrite?

My url scheme is /foo/var1-var2-var3.../bar I am using these mod_rewrite rules: RewriteBase /foo/ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
Daniel's user avatar
  • 125
11 votes
2 answers
45k views

Apache .htaccess error: 'not allowed here' on Debian Wheezy

I am trying to configure an apache virtualhost which needs to be password protected in the root directory. So I created a .htpasswd file (with sha passwords) and configured the .htaccess file. ...
BonifatiusK's user avatar
11 votes
1 answer
75k views

Increase the value of LimitRequestFieldSize in Apache

I have developed an application which uses a jQuery plugin, which in turn uses excessive cookie data. The problem is, after every 15-20 request I am shown this error message by the browser: Your ...
Ibrahim Azhar Armar's user avatar
10 votes
4 answers
21k views

Why do .htaccess redirects work in http but not with https?

I have a simple .htaccess file that works great on the http version of the site but not when I go to https. Why? RewriteEngine on #This is so if the file exists then use the file RewriteCond %{...
Sheldon McGee's user avatar
10 votes
3 answers
43k views

How to redirect from HTTPS to HTTP before server error?

I used to operate a website with an SSL certificate, but have stopped using the SSL certificate. The problem is that most of the external links to the website use the https:// prefix. I have tried ...
user981178's user avatar
10 votes
4 answers
42k views

.htaccess does not ask the password

I am using Ubuntu 12.04 and trying to use .htaccess on a page with apache2 server on it. My .htaccess file looks like this: AuthType Basic AuthName "Password Required" AuthBasicProvider file ...
Sarp Kaya's user avatar
  • 377
10 votes
1 answer
8k views

Exclusion of a protected sub-url does not work on Apache 2.4?

I try to exclude a sub-url "/shop/api" from my protected website. It worked fine on different server on Apache/2.2.15 but now not with Apache/2.4.7? It always asks for the basic authentication. Any ...
megloff's user avatar
  • 413
10 votes
2 answers
32k views

Allow using php_value and php_flag in .htaccess

I am running an Apache web server with PHP5 as a module (notice: as an Apache module, not CGI!). In some of my .htaccess files (the one that comes with the gallery3 software, http://gallery.menalto....
tvooo's user avatar
  • 103
9 votes
3 answers
13k views

Limit upload file size and redirect user to error page if limit exceeds

Is it possible to redirect user to file file too big page when POST request size exceeds specified limit? I am aware about max-request-size option, but it gives just static page that cannot be ...
jonny's user avatar
  • 357
9 votes
2 answers
868 views

Can't figure out a htaccess rule

I have this in my htaccess but can't figure out what its for. Because of the nature of rule, searching doesn't help either. RewriteCond %{REQUEST_URI} !(/$|\.) RewriteRule (.*) %{REQUEST_URI}/ [R=301]...
Richard1984's user avatar
9 votes
1 answer
20k views

Why does my RewriteLog not work?

I have an .htaccess which looks like this: RewriteEngine on RewriteLog "/Applications/MAMP/logs/rewrite_engine_log" RewriteCond %{REQUEST_URI} !/(index.php|css|images|js)/.*$ RewriteRule (.*) /...
openfrog's user avatar
  • 235
9 votes
2 answers
1k views

Dissecting a website attack through a compromised FTP account

My site has been hacked and at this point, I know some details, but I'm at a loss at exactly how it happened or how to prevent it in the future. I need your help in trying to dissect the attack so ...
Dear Abby's user avatar
9 votes
3 answers
5k views

How do I obscure my Wordpress install via htaccess?

(I am aware that security via obscurity is not recommended). I am trying to hide the fact that I am using Wordpress. This post is helpful, but it only addresses the content (sort of). I am interested ...
Son of the Wai-Pan's user avatar
9 votes
5 answers
5k views

How to prevent hot linking ("image theft" / "bandwidth theft") of ressources on my site?

I'm trying to write the "ultimate" anti hot linking .htaccess... You can find many examples/tutorials/generators on the net but many of them are wrong or incomplete (or even both). These are the ...
AlexV's user avatar
  • 179
9 votes
1 answer
3k views

HSTS and double redirect

I manage a little website in a shared hosting LAMP environment: this basically means the only thing I can edit is an htaccess file. I wanted to add HSTS support (and I did it), but, when I tested my ...
user avatar
9 votes
11 answers
2k views

.htaccess doesn't redirect to www-prefixed page properly

I'm trying to redirect an url without www. to www.version (example.com to www.example.com). I use the usual RewriteCond %{HTTP_HOST} ^example\.com [nc] RewriteRule (.*) http://www.example.com/$1 [R=...
cypher's user avatar
  • 91
9 votes
2 answers
12k views

Apache Header Module Loaded but can't set headers in htaccess

I have Apache 2.2.29 (unix) setup and running on my new dev machine (mac). I am trying to set CORS headers for an API project - something that I have done many times. The htaccess file for the ...
Dan Lake's user avatar
8 votes
1 answer
246 views

Create VHost & Forward subdomain to it

Gurus of So I have a simple .htaccess file where I only redirect non www to www for my webapp. Now what I want to do is Create a new vhost like http://subdomain.mydomain.tld Create a redirect for ...
user avatar
8 votes
3 answers
23k views

Apache basic auth for a particular URL

I have a site in production that I want to modify (translate from French to English). The modified part will be placed in the domain.com/en URL location and I want to protect only this part with a ...
Fabien Quatravaux's user avatar
8 votes
5 answers
7k views

Relative substitution in mod_rewrite RewriteRule

I want to create a mod_rewrite RewriteRule which is independent from the location where the web page is installed. I want to define the rewrite rule in a .htaccess file. Let's take this as an example: ...
kayahr's user avatar
  • 313
8 votes
2 answers
9k 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 ...
kovshenin's user avatar
8 votes
2 answers
23k 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 ...
Dean Or's user avatar
  • 222
8 votes
1 answer
9k views

.htaccess Redirect 301 with trailing slash adds trailing slash to destination

Just had my website re-done and am trying to set up redirects in the .htaccess file for links that have changed This works fine, except it doesn't work for /example/ (with trailing slash on source ...
Chris Dutrow's user avatar
8 votes
2 answers
6k views

.htaccess with single page website

I have a single page website with URL parameters that should still open the single index.html (made with Vue.JS and Vue.JS Router). For example, there is www.example.com/, www.example.com/user, and ...
M Zeinstra's user avatar
8 votes
5 answers
11k 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 ...
Danny's user avatar
  • 311
7 votes
5 answers
87k views

How do I use .htaccess to always redirect from HTTP to HTTPS? [duplicate]

There's a few similar questions which I tried to work out the answer from, but so far I have been unsuccessful. Please advise how I can always redirect http to https (and also remove www. from the ...
Nick Bolton's user avatar
  • 5,146

1
2 3 4 5
57