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 need help

Want to make simple htaccess. tasks is: site url = siteurl.com i want to show to users folder siteurl.com/folder, but url must look like siteurl.com only.
RusAlex
  • 188
  • 1
  • 6
1
vote
2 answers

Problem with .htaccess on Ubuntu 10.04

Yesterday I installed LAMP on my Ubuntu 10.04. At first everything seemed fine, but, when I launched my PHP app (I copied it from Windows 7, where I use XAMPP) it didn't accept my .htaccess file. So all of my URLs are broken at the moment. What I…
Eugene
  • 259
  • 1
  • 4
  • 16
1
vote
1 answer

.htaccess file?

Possible Duplicate: .htaccess file? Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask? I am looking for exact code for creating .htaccess file used for redirect a simple static page. Looking forward to positive…
user368993
1
vote
1 answer

Using .htaccess to serve files from Amazon S3 CloudFront

My ideal setup would be to take a current clients site, upload a .htaccess with a regex inside, that would match the URI, and if it finds a certain file extension, it would use the same path, but with an altered domain. ie. Normal…
Adrian A.
  • 85
  • 1
  • 2
  • 12
1
vote
0 answers

Serve a specific set of error pages for different subdirectories

I am currently trying to setup 2 different sets of Error documents for separate folders within a website. I have 2 folders within the root of a site: demo/ live/ Any requests that return 404's or 403's within the demo folder needs to load one set of…
navitronic
  • 111
  • 2
1
vote
2 answers

Redirect subdomain to subdomain on new domain

I own 2 domains sio-india.org and sio-india.com What i want to do is redirect all the subdomains from 1st domain to 2nd domain. eg. home.sio-india.org to home.sio-india.com but i dont want to redirect sio-india.org to sio-india.com and also dont…
Ali
1
vote
3 answers

Redirect Web Subfolder to Root (/folder to /)

I am trying to redirect /folder to / using .htaccess but all am I getting is the Apache HTTP Server Test Page. My root directory looks like this: / .htaccess -/folder -/folder2 -/folder3 My .htaccess looks like this: RewriteEngine On RewriteCond…
manyxcxi
  • 157
  • 3
  • 3
  • 8
1
vote
2 answers

Same index for all (sub-)directories?

I was wondering if it was possible to write some .htaccess page that makes the server use an index.php file in a SINGLE directory as the index file for every directory/sub-directory on my server, rather than placing the exact same index.php in 200+…
whatisthis
1
vote
1 answer

Clean URLS with mod rewrite and URL Encoded characters causes 404?

I have a web site using mod_rewrite to get some clean urls and custom 404 pages. My .htaccess file looks like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?clean_url=$1…
LeguRi
  • 133
  • 7
1
vote
2 answers

Apache+FastCGI Timeout Error: "has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds"

I've recently installed mod_fastcgi and Apache 2.2. I have a simple cgi script as below (test.fcgi): #!/bin/sh echo sadjad But when I invoke 'mysite.com/test.fcgi' I see "Internal Server Error" after a short period of time. The error.log file shows…
Sadjad Fouladi
1
vote
1 answer

mod_rewrite to capture subdomain name

I want to write a rewrite scheme such that: user1.example.net will redirect to example.net/user/user1 user2.example.net will redirect to example.net/user/user2 This is what I have in my .htaccess code. But it always redirects to…
Ricky
1
vote
1 answer

Can htpasswd be used to restrict access to a URL rather than a specific folder?

I would like to restrict access to certain URLs with htpasswd files, rather than folders, is this possible? For example, I wish to restrict the URL: www.example.com/pages/id/227/Restricted_Page But allow access to other URLs such…
me_here
1
vote
1 answer

RewriteRule to only affect first segment

I have the following RewriteRule in place. This rewrites everything that starts with mac, linux or windows: RewriteCond $1 ^(mac|linux|windows) [NC] RewriteRule ^(.*)$ /index.php/site/index/$1 [L] Unfortunately this also rewrites /mac/test/testing.…
user43365
  • 21
  • 3
1
vote
3 answers

.htaccess not loading up on CentOS

For some reason none of my .htaccess files are loading. What are the common things that make this happen? I can use in httpd.conf, and create it there, but it doesn't read .htaccess files in my directories.
matt
  • 111
  • 5
1
vote
2 answers

What is causing this completely bizarre behavior with mod_rewrite?

Here is my rule: RewriteRule ^user/(\d+)$ rewrite.php?id=$1 This redirects, but $_GET['id'] is not set. If I change the above rule to: RewriteRule ^anything/(\d+)$ rewrite.php?id=$1 It works. Why does one work but not the other? Here is more…
Nathan Osman
  • 2,725
  • 7
  • 32
  • 46