views:

155

answers:

3

I need to do a url-rewriting job now.

I don't know whether I should put the code into a .htaccess or httpd.conf?

EDIT

What's the effecting range of .htaccess?Will it affect all requests or only requests to the specific directory it's located?

+1  A: 

Ease of use and IMO maintainability (just go to the dir you want as any permissioned user) = .htaccess but that is parsed repeatedly vs. the parse once in httpd.conf where your über-high volume would be best set.

Xepoch
A: 

You may use both of them. IMHO, .htaccess will be a bit better

at8eqeq3
+1  A: 

If you wont have to change your rules very often, you should put them in the httpd.conf and turn off overriding in the top directory your rules apply to

AllowOverride None

With no overriding, your apache will not scan every directory for .htaccess files making less of an overhead for each request.

Whenever you do have to change your rules, you will have to restart your apache server if you put it in your httpd.conf as opposed to them being instantly detected in .htaccess files because it reads them all on every request.

You can easily do this using a graceful restart with the apachectl tool to avoid cutting off any current requests being served.

apachectl graceful

If you aren't going to turn override off, you might as well just use .htaccess only.

Edit in response to your edit:

Say you have a request for www.example.com/dir1/dir2/dir3/file

Apache will look for a .htaccess file in all 3 of those directories and the root for rules to apply to the request if you have overriding allowed.

Mike
Will it scan .htaccess if AllowOverride is set to none?
Paypal
It wont, you will have to put all your rules in <Directory> tags in the httpd.conf if you turn override off.
Mike