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
2 answers

.htaccess security

In my .htaccess file I've been trying to figure out if I should use: Options None which of course would disable all extra options, but I've been reading mixed opinions concerning the use of "Options None", because some people claim that…
Zero
  • 55
  • 5
1
vote
1 answer

Apache Allow or Redirect users

I'm trying to use a .htaccess to Redirect people that are not from a certain IP range. Redirect is working ok, but I can't figure out how to do both at the same time: - People within a certain range: access to content - People outside of this range:…
Warnaud
  • 115
  • 5
1
vote
3 answers

Does Snow Leopard Server support .htaccess?

I'm working on a site which requires mod_rewrite rules in an .htaccess file. But when uploading the file to this new OSX 10.6 Server install (with Apache 2.2.13) it just disappears. I'm pretty sure that this isn't just invisible files not being…
user57472
1
vote
3 answers

urlrewrite htaccess on symbolic directory

I have a problem using htaccess url rewrite on a symbolic folder. Below is the line which i am using in htaccess file for url rewriting. RewriteRule ^global/css/([0-9]+)/([a-z-_]+)\.css$ global/less/index.php?site_id=$1&file=$2 [L] "global" is…
user57221
  • 297
  • 1
  • 9
  • 19
1
vote
2 answers

Symbolic link bypasses htaccess in apache

I have a protected folder in my server. /var/www/private/ /var/www/private/.htaccess It also has a lot of subfolders with different services. /var/www/private/service1/ /var/www/private/service2/ /var/www/private/service3/ Now, i'd like to shorten…
LatinSuD
  • 901
  • 1
  • 8
  • 17
1
vote
1 answer

.htaccess redirect not preserving http_referer header

We're merging with another company, and we want to redirect content from their (Apache) website to our (IIS) site. When traffic arrives at our site, we inspect the HTTP_REFERER, and if the visitor was just redirected from the company's site that we…
CodeToaster
  • 115
  • 1
  • 3
1
vote
2 answers

Linux Redirect www to non-www using .htaccess

I'm trying to redirect www.example.com to http://example.com using the .htaccess file in my root directory. I've tried the examples listed here and elsewhere. rewriteengine is on. rewriteCond %{HTTP_HOST} ^www\.(.*) [NC] rewriteRule (.*) //%1/$1…
Geo
1
vote
1 answer

crntab and htaccess

I need to call a php script via cron. The cron entry will use wget. When I attempt to call the script from a command line, I get "Authorization Required", which is obviously coming from my htaccess file. Does anyone know how I can override the…
user55999
1
vote
1 answer

apache error log for rewrite rule

i am getting following error in apache log File does not exist: D:/wamp/www/script/products, referer: http://localhost/script/products/category/product-123.html whenever following url localhost/script/products/category/product-123.html is parsed…
Imran Naqvi
  • 111
  • 2
1
vote
1 answer

Convert Old .htaccess rules to IIS Rewrite Rules

I've started to host my own site on IIS and it was previously hosted on DreamHost on Apache so I have an .htaccess file with rewrite rules I would like to convert to the URL Rewrite module rules. # initialize mod_rewrite RewriteEngine on RewriteBase…
Tom Bell
  • 115
  • 5
1
vote
2 answers

.htaccess rewrite with drupal and clean urls on mamp stack

I'm having an unusual access problem with Drupal running on a MAMP stack. The Drupal install is working fine, so I know it's not a Drupal issue. "Clean URLs" are working fine for anything with a single-level url, but nothing with 2+ path levels. For…
TwstdElf
  • 11
  • 3
1
vote
1 answer

How to redirect a subdomain with subfolders to a domain using the same subfolders and the subdomain itself as parameter?

So I would likte to redirect this url: http://subdomain.domain.com/subfolder/subsubfolder/ to: http://www.domain.com/subfolder/subsubfolder/?parameter=subdomain And also using other, more, less or no subfolders. I found this, but it doesn't seem to…
Diederik
  • 111
  • 3
1
vote
1 answer

Index File in .htaccess

This is the content of my .htaccess file: php_flag allow_url_fopen on DirectoryIndex index.php AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript…
Gerardo
  • 111
  • 3
1
vote
1 answer

My CSS files are refered as PHP

some other programer before me made some changes on server, and now if i call html files, they are treated as php. if html file like that have included css it is also treated as php, and it makes problems... they tryed to connect to mysql database,…
user48058
  • 863
  • 3
  • 12
  • 20
1
vote
2 answers

Apache .htaccess 403 a directory

I have an /uploads directory I wish to block from direct access. Of course I would put it outside the web root, but I'm really looking at a quick .htaccess fix. Is there a way I can 403 or 404 a directory?
Benbob
  • 277
  • 1
  • 6
  • 19