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
1 answer

Can't get .htaccess to work

I'm using Apache2 on Ubuntu Lucid Lynx. I have config set to use .htaccess like normal. This is my default site: ServerAdmin webmaster@localhost DocumentRoot /var/www Options…
orokusaki
  • 2,763
  • 4
  • 32
  • 43
1
vote
2 answers

htaccess with conditional rewritebase

I have a site (the-tack-shop.co.uk) in which I'm testing my e-commerce framework on. I was trying to test payment using a shared SSL: https://web43.secure-secure.co.uk/the-tack-shop.co.uk/. I had to change my htaccess file to work with the…
Phil Jackson
  • 111
  • 1
  • 3
1
vote
1 answer

What's the correct Apache syntax for proper expiration cache control?

Some questions on the absolute, optimal usage of caching of dynamic and static cache. Currently, my htaccess is setup as below, and I have the feeling im not really using it the correct way... Any of your improvement-suggestions I see as answers!…
Sam
  • 423
  • 3
  • 7
  • 23
1
vote
1 answer

Keeping the original subdomain url in the address bar with wildcard subdomains

How can I change my rewrite rule to keep the original subdomain url in the address bar? Currently if I type in "username.domain.com" it gets redirected to "domain.com/username"...and I would like the address bar to stay at "username.domain.com". I'm…
Ronedog
  • 135
  • 3
  • 6
1
vote
2 answers

Why do two patterns (/.*) and (.*) match different strings?

Shouldn't the two patterns (/.*) and (.*) match the same string? My real question is actually: where did the "abc" go? Something funky seems to be happening inside the mod_rewrite engine... Given this .htaccess file in www/dir/: Options…
Leftium
  • 293
  • 2
  • 8
1
vote
7 answers

.htaccess Permission denied. Unable to check htaccess file

I have a strange problem when adding a sub-domain to our virtual server. I have done similar sub-domains before and they have worked fine. When I try to access the sub-domain I get an 403 Forbidden error. I checked the error logs and have the…
Josh
  • 111
  • 1
  • 5
1
vote
3 answers

.htaccess https redirect problem

I've got a directive set up in my htaccess to send all non-https traffic to https RewriteCond %{SERVER_PORT} ^80$ RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] # These are used by the Zend Framework... RewriteCond %{REQUEST_FILENAME}…
Dave
  • 21
  • 4
1
vote
1 answer

htaccess will not work

On my new vps.net server .htaccess does not work. mod_rewrite is what the .htaccess is trying to do. These are the steps I have done so far: Added: Order allow,deny Allow from all AllowOverride…
JD Isaacks
  • 895
  • 5
  • 14
  • 25
1
vote
1 answer

Redirect from folder containing website

I have a website reached from this url: http://www.mysite.com/cms/index.php being served from this directory: public_html/cms/index.php In public_html I have this .htaccess RewriteRule (.*) cms/$1 [L] Which lets me get to the site like…
Sam
  • 2,020
  • 1
  • 16
  • 22
1
vote
1 answer

ForceType/SetHandler code - why does this work?

I tried this code, although it works for some reason, aren't there mistakes in it? I'm not sure what the best way to correct this is, but here it is... ForceType application/x-httpd-php SetHandler…
JDoe86
  • 11
  • 1
1
vote
1 answer

Restrain SSPI Auth to one page, Apache conf

I need to have SSPI auth on the adress " / ", but not on the rest of the site I've tried this configuration : AuthType SSPI AuthName "XXXX" SSPIAuth On SSPIAuthoritative On SSPIOfferBasic On …
1
vote
1 answer

.htaccess modify rules and redirect if there's .php in the url

I got the following code in my .htaccess: Options +FollowSymlinks RewriteBase /temp/test/ RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^about/(.*)/$ $1.php [L] RewriteRule…
Ron
  • 113
  • 4
1
vote
1 answer

Apache SSL for login and NON-SSL for everything else (.htacces)

I've almost figured it out on my own but there's something I'm missing. I want to set a couple of directories and files to require SSL and everything else that's not related to those files and dirs to point back to http. So far I have…
tftd
  • 1,498
  • 7
  • 25
  • 40
1
vote
1 answer

localhost won't load after adding directives to httpd on WAMP Apache 2.2xx

I am not very experienced with configuring httpd, and I am following a tutorial to view my site w/ domain name under localhost. My localhost just blanks out and my apache services won't restart. I checked all of my paths and they are correct. I am…
OldWest
  • 141
  • 1
  • 7
1
vote
1 answer

.htaccess not behaving on all pages

The .htaccess file works correctly when I enter the homepage. Then when I click through to another page I get this on the top and bottom of my page with some missing parts for that page: Authorization Required This server could not verify that…
Kyle Parisi
  • 115
  • 5