Ubuntu/apache2

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
(redirect)
Line 32: Line 32:
 
  sudo a2enmod rewrite
 
  sudo a2enmod rewrite
 
====redirect====
 
====redirect====
'''Request:''' redirect all traffic from a domain, including any subpage, to the landing/index page of another domain
+
'''Request:''' redirect all traffic from a domain, including any subpage, to the landing/index page of another domain<br>
'''Condition:''' mod_rewrite is enabled.  virtual hosts are used
+
'''Condition:''' mod_rewrite is enabled.  virtual hosts are used<br>
 
'''Resolution:'''  
 
'''Resolution:'''  
 
  <VirtualHost *:80>
 
  <VirtualHost *:80>

Revision as of 21:38, 29 September 2014

apache2 is the most popular web hosting application on the market today


start|stop|restart apache2

sudo /etc/init.d/apache2 start|stop|restart

OR

sudo service apache2 start|stop|restart

apache2 enable site

a2ensite [site config file name]
i.e. a2ensite default-ssl

apache2 disable site

a2dissite [site config file name]
i.e. a2dissite default-ssl

apache2 enable module

a2enmod [module]
i.e. a2enmod mod_ssl

apache2 disable module

a2dismod [module]
i.e. a2dismod mod_ssl

disable indexing

~$ sudo a2dismod autoindex
Module autoindex disabled.
To activate the new configuration, you need to run:
  service apache2 restart

mod_rewrite

very power, very confusing tool.
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
http://httpd.apache.org/docs/current/rewrite/remapping.html

enabling

was not enabled by default for my ubuntu 14.04 vm.

sudo a2enmod rewrite

redirect

Request: redirect all traffic from a domain, including any subpage, to the landing/index page of another domain
Condition: mod_rewrite is enabled. virtual hosts are used
Resolution:

<VirtualHost *:80>
        RewriteEngine on
        RewriteCond %{REQUEST_URI} !^/index.html$
        RewriteRule .* http://newdomain.com [R=302,L]
        ServerName olddomain1.com
        ServerAlias olddomain2.com
        Redirect permanent / http://newdomain.com/
</VirtualHost>

<VirtualHost *:80>
        ServerName newdomain.com
        ServerAdmin admin@newdomain.com
        DocumentRoot /var/www/newdomain.com
        TransferLog /var/log/apache2/newdomain.com-access_log
        ErrorLog /var/log/apache2/newdomaincom-error_log
</VirtualHost>
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki