# Apache Server - [.htaccess](#.htaccess-file) - [what is apache module](#apache-module) - [virtual host ](#virtual-host) - [cgi vs wsgi](#cgi-vs-wsgi) ## .htaccess file ### what is .htaccess file ? > .htaccess stands for "hypertext access." > >The .htaccess file is a configuration file that controls how a webserver responds to various requests. It is supported by several webservers, including the popular Apache webserver used by most commercial web hosting providers. > >.htaccess files operate at the level of a directory (https.conf runs when the server starts), allowing them to override global configuration settings of .htaccess directives higher in the directory tree. ### Redirect vs. Rewrite > There are two different ways to "change" a URL with .htaccess directives — the Redirect command and the mod_rewrite engine. > __redirect__ command actually sends a redirect message to the browser, telling it what other URL to look for. > Typically, the __mod_rewrite__ tool "translates" one URL (the one provided in a request) into something that the file system or CMS will understand, and then handles the request as if the translated URL was the requested URL. When used this way, the web browser doesn't notice that anything happened > The mod_rewrite tool can also be used to produce 301 redirects that work the same way as the Redirect command, but with more options for rules — mod_rewrite can have complex pattern matching and rewriting instructions, which Redirect cannot take advantage o ## apach module > The modules allow for Apache to perform additional functions, such as natively rewriting URLs to support SSL encryption ## virtual host ### what is virtual host ? ### hos to add a new virtual host or edit host ? ## cgi-vs-wsgi __WSGI__ is specific to Python - What is WSGI? It allows the Python web app or framework to be a long-running process and talk to the web client via a front-end web server. Other languages have similar facilities, for example Rack for Ruby. __CGI__ is general to any language - What is CGI? It connects to the client through the web server using a request/response mechanism. A new process is spawned for each request, which worked during the early days of the web but is no longer feasible. >WSGI runs the Python interpreter on web server start, either as part of the web server process (embedded mode) or as a separate process (daemon mode), and loads the script into it. Each request results in a specific function in the script being called, with the request environment passed as arguments to the function. > >CGI runs the script as a separate process each request and uses environment variables, stdin, and stdout to "communicate" with it.