Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to edit the htaccess file on my server. Problem is, I can't find it. Any idea where it would be?

share|improve this question
1  
Where did you put it? –  andol Jul 18 '10 at 15:19
add comment

8 Answers

It's possible it doesn't exist, but it belongs in your document root which may be /var/www, /usr/local/apache2/htdocs, /var/www/html or others. You can see what the locations are for various distributions here. You can also place it in other directories to control portions of your site differently.

share|improve this answer
    
Yeah, check your apache configuration file to find your document root. For me (Ubuntu) it's here: /etc/apache2/sites-available/name-of-virtual-domain. –  Antonius Bloch Apr 17 '11 at 21:14
add comment

Don't. Edit the main Apache configuration file instead. (I'm assuming you have access to it because it's your server) The .htaccess file is a file that people can create to apply certain configuration directives when they don't have access to the main server configuration, but Apache can handle requests more quickly and easily when it doesn't have to bother with .htaccess files.

On Linux the main server configuration file is usually at /etc/apache2/httpd.conf or /etc/apache2/apache2.conf, and it typically uses an Include directive to incorporate other files which may be in subdirectories of /etc/apache2. If you're using a non-Linux system, I'm not sure where the config file would be, but it should be documented on the Apache website.

If you don't have access to the main server configuration, the .htaccess file should be created in the directory you want its directives to apply to.

share|improve this answer
    
"Don't"? What a lame answer, he didn't ask for your opinion he asked where to find the stupid file. –  troyengel Jul 18 '10 at 15:04
    
@troyengel: It's not an opinion, it's the best practice as explained in the Apache documentation itself. And I did also answer the question as asked. –  David Z Jul 18 '10 at 20:37
add comment

You create the file in each folder you want those settings to apply to.

See the Apache documentation for more information.

share|improve this answer
add comment

Create a file named ".htaccess" in the root level of your web accessible folder and see if that has an effect.

share|improve this answer
    
ah...I didn't realize I had to create one. Thanks –  codedude Jul 18 '10 at 2:21
add comment

If you know where your web root starts, then as an example:

find /var/www/html -name .htaccess

If you have no clue, then brute force the entire filesystem:

find / -name .htaccess

Not pretty, but it works if you have no idea where things are on your server. Be prepared to wait while it churns.

share|improve this answer
    
And what if there is no .htaccess file? What if there is one, but it's not in the directory the OP wants to apply directives to? What if there are several? Still, I'm going to take the high road and not downvote you because this could be useful... –  David Z Jul 18 '10 at 20:44
    
...then the OP would follow up with these questions. He asked how do I find it, this is how you find it. Downvote me if you want out of spite, the answer is correct to the question and not in error. –  troyengel Jul 19 '10 at 16:07
add comment

Where ever your public/htdocs folder is.

share|improve this answer
add comment

You may not have a .htaccess file for the portion of your server that you can see. If no file is present, then whatever settings are specified in the parent folder are applied, up to the point that the base configuration of apache is applied.

So, as ars said, if you don't see it, create it for the directory that you want to affect. And as a sidenote, if you want different settings for different folders, go for it!

share|improve this answer
add comment

.htaccess files can go in any directory under the document root, so there can be more than one. There can also be none. And, depending on your system configuration or FTP client, you may just not be able to see it, because it starts with a period.

Try ls -a or change the filtering options in your FTP client to show files starting with .

Docs: http://httpd.apache.org/docs/2.1/howto/htaccess.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.