Httpd.conf Customization putting stuff in the right place

gdjun

Verified User
Joined
Nov 14, 2008
Messages
18
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
 
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
 
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?

Code:
<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
 
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?
 
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:
Code:
...
|?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
Code:
|?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 featurewhich 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:
Code:
|*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
 
please help me i have two domain api.site.com and site.com . i want to change httpd for api.site.com and site.com

|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/frontend|
|?DOCROOT=`HOME`/domains/api.`DOMAIN`/public_html/backend|

also i try with this but not work

Code:
|*if DOCROOT="/home/mailerchiir/domains/mailerchi.ir/public_html"|
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/frontend|
|*endif|

Code:
|*if DOCROOT="/home/mailerchiir/domains/api.mailerchi.ir/public_html"|
|?DOCROOT=`HOME`/domains/api.`DOMAIN`/public_html/backend|
|*endif|
 
please help me i have two domain api.site.com and site.com . i want to change httpd for api.site.com and site.com

|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/frontend|
|?DOCROOT=`HOME`/domains/api.`DOMAIN`/public_html/backend|

also i try with this but not work

Code:
|*if DOCROOT="/home/mailerchiir/domains/mailerchi.ir/public_html"|
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html/frontend|
|*endif|

Code:
|*if DOCROOT="/home/mailerchiir/domains/api.mailerchi.ir/public_html"|
|?DOCROOT=`HOME`/domains/api.`DOMAIN`/public_html/backend|
|*endif|

See step 6a and 6b. i think they will help you.
 
Back
Top