PDA

View Full Version : Httpd.conf Customization putting stuff in the right place



gdjun
10-29-2010, 03:59 AM
Hello,

I'm trying to put some mod_rewrite rules in the custom httpd conf for a particular domain, rather than in htaccess. How do i make sure it goes in the right section of the conf file?

I'm trying to insert:
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

but that has to go into the directory part of the config, help

nobaloney
10-29-2010, 01:36 PM
If the default position doesn't work for what you want to do you need to do a shell root login and make manual changes to the file. Then you need to chattr the file immutable so DirectAdmin won't ever change it.

Jeff

gdjun
11-02-2010, 02:58 AM
Supose everybody else knew that (nOOb mode) Rewrite-rules can go directly into the virtualhost declaration, so entering them in the Httpd.conf Customization area worked out fine.

Now i still have the question: if i "wanted" to add something to the directory part of a domain, how would i declare it in Httpd.conf Customization?


<VirtualHost 10.0.0.1:80 >
ServerAlias example.com
...
<Directory /home/user/domains/example.com/public_html>
.. add stuff here... how?

In php i can check for uppercase and trailing-slash in one run and redirect if needed, whereas RewriteLog for similar, shows all kinds of internal redirects and sub-requests. Is mod_rewrite the way to go? Say, beyond the easy -f and -d and removing index.php from the url? Is it less of a strain on the server than php?

Quote from the mod_rewrite module page: "Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo." -- Brian Moore

DirectAdmin Support
11-02-2010, 10:31 PM
Hello,

1) Use this (http://help.directadmin.com/item.php?id=2) to move the |CUSTOM| token to a new spot in the virtual_host configs.

2) Then use this (http://help.directadmin.com/item.php?id=3) to add any custom code you want for any domain, as needed.


Note, that you can get very creative while using the if-then-else statements, combined with custom variables, custom package items, etc..

Related:
http://help.directadmin.com/?query=cust_httpd
http://help.directadmin.com/item.php?id=294

John

gdjun
11-06-2010, 05:05 AM
Thanks for the reply. I saw the page from your (1) example before, but it was hocuspocus to me. From what i read there, you can move the |CUSTOM| part in a general copy to custom-conf, but i still have no idea how you could add stuff in two place in a configuration. Say, some directory stuff inside the <Directory>... part and RewriteRules in the general part.

Something like this:
|*directory |DOCROOT||
#custom item for just this directory
|*endif|

|*directory=/home/user/domains/example.com/public_html/products|
AllowOverride none
|*endif|

Or am i completely missing something and could you just add a <directory>... part and would both get parsed by apache?

DirectAdmin Support
11-06-2010, 02:39 PM
I have two answers for you, each one will accomplish different things.

1) To add custom bits into 2 places via varaibles:

Leave the |CUSTOM| part up higher up (it's default location), in:
Admin Level -> Custom http config -> domain.com

and then you can set your own variables using it.

So, in the custom/virtual_host2*.conf files, you'd have something like:
...
|?CUSTOM_BIT=|
<VirtualHost>
|CUSTOM|

#put the custom bit anywhere:
|CUSTOM_BIT|
</VirtualHost>So by default the CUSTOM_BIT variable is blank. But then you go to the custom http config for that domain, and add
|?CUSTOM_BIT=some code you want|and voila, you've got code in other places. You can have as many variables as you want, named pretty much whatever you want.


2) Since this is a template, you can use this feature (http://www.directadmin.com/features.php?id=430)which allows for if-then-else statements in all templates, similar to what you're looking for. The code you've got is close, it's just missing the "if" question, eg:
|*if DOCROOT="/some/value"|
#custom item for just this directory
|*endif|
|*if DOCROOT="/home/user/domains/example.com/public_html/products"|
AllowOverride none
|*endif|etc.. Note that you can specify variables within an if-statment.


On top of that, you can also use php embedding in the virtual_host files, which gives you essentially the ultimate control. You could hit a database backend if you wanted to.
http://www.directadmin.com/features.php?id=756

John