Where should put RewriteCond and RewriteRule? [duplicate]
I am using Apache as the HTTP server in order for me to access the Subversion repository, since I don't find any .htaccess
file as I am not tied the svn directory to /var/www
, can I put the RewriteCond
and RewriteRule
in httpd.conf
?
Solution 1:
The documentation provides a fairly standard block of information for every Apache directive.
RewriteCond Directive
Description: Defines a condition under which rewriting will take place
Syntax: RewriteCond TestString CondPattern
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Extension
Module: mod_rewrite
Note the Context:
This tells you where a particular directive may be used.
Solution 2:
Putting these in httpd.conf
(in your virtual host section for the repositories) is certainly possible. Additionally, if you are including the virtual host by reference to another configuration file, you should put the mod_rewrite directives in there.
I actually find it preferable to do this; .htaccess
files should be disabled whenever possible. This is particularly true on sites to which users can upload content, to minimize security exposure and keep configuration completely out of band. It also has performance implications -- the .htaccess
file is reread every time a URL to which it might apply is accessed, because it can change without a configuration reload, whereas the actual server configuration is only reevaluated when rehashing or starting apache.