It depends on the directives being used in the .htaccess
file.
You can't necessarily simply copy (or include) the same directives from .htaccess
and use them unaltered in a server or virtualhost context, which is suggested here. .htaccess
files work in a directory context, so you can potentially copy them verbatim into a corresponding <Directory>
container inside the vHost or server config.
The notable directives here are mod_rewrite - which work differently in a server (or virtualhost) context vs .htaccess
(or directory) context.
For example, if the .htaccess
file is located at /var/www/user/public_html/.htaccess
then you could use the following in the vHost container instead:
<Directory /var/www/user/public_html>
# Disable .htaccess overrides
AllowOverride None
# .htaccess directives go here...
# :
</Directory>
However, you may not want to do this. It might be preferable to modify the directives so they work in a virtualhost context instead. Unless you completely disable .htaccess
overrides (as mentioned above with AllowOverride None
and possibly AllowOverrideList
) then any .htaccess
file along the filesystem path will override the <Directory>
container in the vHost.
Adding server configs to .htaccess
can slow things down
Note that in order to get the (marginal) performance benefit, you need to completely disable .htaccess
overrides in the server config (as mentioned above). Simply removing the .htaccess
file(s) is not sufficient since the server will still search for them in every directory along the requested filesystem path.
.htacess
file in the root directory of each host. There's no need to add any conf files... – eyoung100 Aug 27 '16 at 20:12