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

Access Rails under /app/, not /app/public/

I'm trying to deploy Rails 2.1.2 with Apache 2.2.10 and FastCGI (yeah, bad, ancient, ugly, I know). My application can be accessed via example.com/app/public/, but I want to access it via example.com/app/. In my .htaccess-File (in the…
blinry
  • 111
  • 3
1
vote
1 answer

Is it possible to write an htpasswd file that redirects certain users to certain directories?

Assuming that I have a domain, say, mydomain.com and three directories under it call them dir1, dir2 and dir3, then is it possible to put an htpasswd file at the web root and have it redirect authenticated users to their respective directories (e.g.…
user41157
  • 189
  • 2
  • 9
1
vote
1 answer

Multiple domains, one config, hosted on apache2

First a quick disclaimer, I'm not a 'server guy' or a 'unix pro' or anything like that, I'm a web programmer who got stuck doing server works since I ran linux (ubuntu) on my netbook. I'm trying to set up an apache server running on Debian to…
1
vote
1 answer

How to setup http redirect for links to other urls on my site?

I'm trying to use cname and http redirect to hide that I'm linking to other domains on my site. I know how to setup the cname through my hosting service, but I'm unsure how to setup the http redirects. Do I need to setup each redirect link in the…
B Lee
1
vote
1 answer

Folder isn't visible

I have the latest apache under Arch Linux. Here is the screen: alt text http://uppix.net/f/a/b/1f323092f2485e2f1e8e59c3744bf.png [ockonal@wincode public_html]$ ls -l total 1 drwxr-xr-x 10 ockonal users 432 May 2 16:48 site drwxrwxrwx 11 ockonal…
Max Frai
  • 125
  • 3
1
vote
1 answer

htaccess allow if does not contain string

I'm trying to setup a .htaccess file which will allow users to bypass the password block if they come from a domain which does not start with preview. e.g. http://preview.example.com would trigger the password and http://example.com would…
Tom
  • 766
  • 3
  • 9
  • 24
1
vote
1 answer

How do you access an httpd.conf Environment variable in .htaccess?

This doesnt seem to work in .htacces: SetEnv FOO %{ENV:BASH}
qodeninja
  • 2,753
  • 10
  • 32
  • 33
1
vote
1 answer

Compression without Mod_Deflate

Greetings all, After running tests with Google PageSpeed, I believe my site could really benefit from compressing js/html/css/php files. Unfortunately, my host (Host Gator) does not support Mod_Gzip or Mod_Deflate. I was able to enable php…
pws5068
  • 155
  • 3
1
vote
3 answers

HTACCESS Rewrite problem

I have this folder structure: /var/www/mysite/abc/ /var/www/mysite/def/ /var/www/mysite/fgh/ /var/www/mysite/ijk/ /var/www/mysite/portal/ /var/www/mysite/wyz/ Today's my server is redirecting all requests of www.mydomain.com to…
Thiago Belem
  • 135
  • 1
  • 3
  • 12
1
vote
2 answers

Having trouble searching for a ‘.’ using htaccess

I'm setting up a website that (ideally) would allow users to access other users' homepages with a url in the format "www.mysite.com/ThisLanham" where 'ThisLanham' is the username. The username begins with a letter and can consists of any…
ThisLanham
1
vote
2 answers

301 Redirect and query strings

I am looking to create a 301 redirect based purely on a query string see b OLD URL: olddomain.com/?pc=/product/9999 New URL: newurl.php?var=yup My normal way of doing this would be redirect 301 pc=/product/9999 newurl.php?var=yup But this time I…
icelizard
  • 732
  • 3
  • 10
  • 20
1
vote
2 answers

Use .htaccess to block *All* access to specific folders

I am not sure how to do this, but I want to block all access to a specific set of folders on my web server. Say secret01 and secret 02... homeDir |- data |- www | |- .htaccess (file) | |- images | |- js | |- secret01 | |-…
Urda
  • 518
  • 4
  • 16
1
vote
2 answers

htaccess problem

I have a few lines in my .htacess Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^mydomain.org [NC] RewriteRule ^(.*)$ http://www.mydomain.org/$1 [L,R=301] # index.php to / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\…
Holian
1
vote
3 answers

Blocking an IP range without using .htaccess

I have a WordPress blog that I am hosting using NearlyFreeSpeech.net. Recently, Russians found it and have been comment spamming me. I don't want to have to trash 30+ Cyrillic comments/day, and I don't want to pay for that bandwidth either. I did a…
Chris
  • 347
  • 3
  • 6
  • 13
1
vote
1 answer

Redirect domainA.com to sub.domainB.com

Just a short and easy question, I hope. Currently, I've got a primary domain linked to my (virtual) hosting server. I now have a second domain name which I would like to link to a specific subdomain, i.e. domainB.com/X ->…
Duroth
  • 111
  • 2