9

I'm looking for the best way to highlight Apache HTTP configuration :

Here an example with lang-xml, which really does not satisfy me:

<VirtualHost *:80>

  ServerName myapp-homintranet.myorg.com
  ServerAlias myapp-homintranet
  
  ProxyRequests Off
  ProxyPass /myapp balancer://jbosscluster/myapp stickysession=JSESSIONID nofailover=On
  ProxyPassReverse /myapp http://server01.myorg.com:8080/myapp
  
  #Conf load-balancing Jboss
  <Proxy balancer://jbosscluster>
    BalancerMember http://server01.myorg.com:8080
    BalancerMember http://server02.myorg.com:8080
    ProxySet lbmethod=byrequests
  </Proxy>

</VirtualHost>

Here an example with lang-java, a bit better, but not yet enough:

<VirtualHost *:80>

  ServerName myapp-homintranet.myorg.com
  ServerAlias myapp-homintranet
  
  ProxyRequests Off
  ProxyPass /myapp balancer://jbosscluster/myapp stickysession=JSESSIONID nofailover=On
  ProxyPassReverse /myapp http://server01.myorg.com:8080/myapp
  
  #Conf load-balancing Jboss
  <Proxy balancer://jbosscluster>
    BalancerMember http://server01.myorg.com:8080
    BalancerMember http://server02.myorg.com:8080
    ProxySet lbmethod=byrequests
  </Proxy>

</VirtualHost>

I didn't find any extension for Google Prettify and Apache HTTP. So, is there any language closer to this syntax? Do you know another way to highlight it?

4
  • Do you have an example of how you'd prefer it to be highlighted?
    – Tim Stone
    Commented Jun 16, 2012 at 23:14
  • I don't have some real example, ... maybe vi / vim syntax highlighting would be the best ? Commented Jun 18, 2012 at 11:23
  • You can now use lang-apacheconf to get syntax highlighting for Apache configurations.
    – Johannes
    Commented Dec 27, 2020 at 12:35
  • @Johannes while that language is available in highlight.js, Stack Exchange doesn't load it. There is no "apache" anywhere to be found in dev.sstatic.net/js/highlightjs-loader.en.js Commented Oct 23, 2021 at 9:52

2 Answers 2

8

I'm not sure .htaccess syntax highlighting is a very high demand form. However, the lang-bsh syntax highlighting looks pretty decent:

<VirtualHost *:80>

  ServerName myapp-homintranet.myorg.com
  ServerAlias myapp-homintranet

  ProxyRequests Off
  ProxyPass /myapp balancer://jbosscluster/myapp stickysession=JSESSIONID nofailover=On
  ProxyPassReverse /myapp http://server01.myorg.com:8080/myapp

  #Conf load-balancing Jboss
  <Proxy balancer://jbosscluster>
    BalancerMember http://server01.myorg.com:8080
    BalancerMember http://server02.myorg.com:8080
    ProxySet lbmethod=byrequests
  </Proxy>

</VirtualHost>

At least it doesn't highlight all the URLs as comments past the //...

Personally, I would just use lang-none for plain black text.

2
  • Ideed, lang-bsh is almost suffisient. I'm waiting for other replies, but it seems that's the better answer it could be given (at least, what I was expecting) Commented Jun 18, 2012 at 11:25
  • Well, I didn't actually test them all, but a list of all the available ones you can use can be found here. You're free to switch them out one by one, but if nothing there is satisfying, then no, there's nothing better you can use.
    – animuson StaffMod
    Commented Jun 18, 2012 at 17:54
3

We should be able to use lang-apache. The hightlight.js demo (look in the "web" category) shows that it supports "Apache Config" now.

highlight.js demo apache

However, despite Stack Exchange using highlight.js, this syntax highlighting does not work here. StackExchange doesn't use all the languages available in highlight.js to keep the size of the JavaScript reasonable. At some point, SE may revamp how syntax highlighting JS is loaded so that all languages can be supported.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .