How to define Custom variable in httpd.conf of Apache Http Server ?
Hi All ,
I need to write 14-15 rewrite rules in httpd.conf, in which i want to redirect some specific url patterns to other domain.
For Ex.
RewriteRule ^/url-id$ http://www.abc.com/de/url-id
But i want to write it in generic way so that i can change domain abc.com to any test.abc.com.
For that i need to change all 14-15 rewrite rules. So is there any way to define custom variable in httpd.conf file so that i can assign destination host & can use it in rewrite rule like in following .
ContentServer = http://www.abc.com
RewriteRule ^/url-id$ ${ContentServer}/de/url-id
So user can only change ContentServer property & it will reflect in all rewrite rule.
pr0gr4mm3r posted this at 14:14 — 29th December 2008.
He has: 1,502 posts
Joined: Sep 2006
Try this:
jonathb posted this at 10:14 — 13th December 2010.
They have: 1 posts
Joined: Dec 2010
No, IMO SetEnv won't do. All SetEnv does is define an environment variable for export into child processes. But that variable you've defined is not available to the httpd.conf script in which it was created. Only those environment variables passed at the birth of that process are available.
- So unfortunately you need to already have that env-var defined when httpd fork-execs, if you want to use it in httpd.conf
- So, one again, the q is:
- how do you define a variable in your httpd.conf script that you can use further down in the same httpd.conf script?
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.