I am trying to use an .htaccess file to create clan URL for my website. I want to test it on my local version of the site and the upload to the server if I succeed.

The question is, where do I have to put the .htaccess file? (I am using LAMP)

Right now my page's index.php file is in var/www/project/

Should I place the .htaccess file here, and can I have multiple .htaccess files?

If I have another project in folder var/www/project2 and want to set redirect rules for that site too, and some of the rules are different than the ones set on the first project, how can I handle that?


You can configure your rules both in .htaccess and per directory / file / alias... in the apache configuration.

If you uses .htaccess files, you can set them anywhere starting from your server root, and it will have effect on any child folder.

Thus if /var/www is your server root, then /var/www/.htaccess will be checked for both project & project2.

Conversely, /var/www/project/.htaccess will only have effect on this folder and its children, not on /var/www/project2 .

  • Sorry, my rep is so low I can't even vote up. Thank you for your answer, It clears things a lot for me.
    – ppp
    Jan 26 '12 at 6:14
  • @AnPel - you can, however, accept Geoffroy's answer, which you should do if you're satisfied with it.
    – EEAA
    Jan 26 '12 at 6:15
  • Can the .htaccess be dynamically generated in any ways?
    – ppp
    Jan 26 '12 at 7:06
  • You can, but the better way is to update apache's configuration directly, because .htaccess have an impact on performance.
    – Geoffroy
    Jan 26 '12 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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