In this paper, we present a general and extensible context-aware computing ontology (CACOnt) for modeling context and providing inference mechanisms. CACOnt provides not only the generic context ontologies for capturing basic concepts about context, but also the extensibility for adding domain-specific ontologies in a hierarchical manner. CACOnt facilitates the context reasoning capabilities by providing semantic logics which is possible to combine with rule-based systems. However, the set of rules cannot entirely cover the domain of contexts, we present a semantic similarity-based rule matching algorithm as the solution to this problem.