Saturday, February 3, 2018

.htaccess file location



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?


Answer



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 .


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...