Apache

VirtualHost

<VirtualHost *:80>
        ServerAdmin webmaster@nofxx.com
        DocumentRoot /var/www/sites/xx.nofxx.com
        ServerName xx.nofxx.com
        ErrorLog logs/xx.nofxx.com-error
        CustomLog logs/xx.nofxx.com-access common
</VirtualHost>
 
 
<VirtualHost *:80>
        ServerAdmin webmaster@nofxx.com
        DocumentRoot /var/www/sites/xx.nofxx.com
        ServerName xx.nofxx.com
        ErrorLog logs/xx.nofxx.com-error
        CustomLog logs/xx.nofxx.com-access common
       <Directory /var/www/sites/xx.nofxx.com/xxx>
#              Options ExecCGI FollowSymLinks
#              AddHandler cgi-script .cgi
               AllowOverride all
               Order allow,deny
               Allow from all
       </Directory>
 
</VirtualHost>

Mongrel Proxy

Apache auth mongrel

<VirtualHost *:80>
        ServerAdmin webmaster@nofxx.com
#       DocumentRoot /var/www/sites/rails.nofxx.com
        ServerName rails.nofxx.com
        ServerAlias rails.nofxx.com
 
        <Proxy balancer://mongrelxcluster>
                BalancerMember http://localhost:6611
                BalancerMember http://localhost:6612
                BalancerMember http://localhost:6613
                #BalancerMember http://localhost:6614
        </proxy>
 
        # TO MONGREL
 
        ProxyPass / balancer://mongrelxcluster/
        ProxyPassReverse / balancer://mongrelxcluster/
        ProxyPreserveHost on
 
        <Location / >
                AuthType Basic
                AuthName "xRails"
                AuthUserFile /var/www/sites/.railspass
                Require valid-user
        </Location>
 
        ErrorLog logs/rails.nofxx.com-error
        CustomLog logs/rails.nofxx.com-access common
</VirtualHost>
 
 
 
<VirtualHost *:80>
        Servername rails.nofxx.com
        ServerAlias rails.nofxx.com
 
        <Proxy balancer://mongrelcluster>
                BalancerMember http://localhost:6601
                BalancerMember http://localhost:6602
                BalancerMember http://localhost:6603
                #BalancerMember http://localhost:6604
        </proxy>
 
        # TO MONGREL
 
        ProxyPass / balancer://mongrelcluster/
        ProxyPassReverse / balancer://mongrelcluster/
        ProxyPreserveHost on
 
	RewriteEngine On
        # Prevent access to .svn directories
        RewriteRule ^(.*/)?.svn/ - [F,L]
        ErrorDocument 403 "Access Forbidden"
 
 
        # Check for maintenance file and redirect all requests
        RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
        RewriteCond %{SCRIPT_FILENAME} !maintenance.html
        RewriteRule ^.*$ /system/maintenance.html [L]
 
 
        # Rewrite index to check for static
        RewriteRule ^/$ /index.html [QSA]
 
 
        # Rewrite to check for Rails cached page
        RewriteRule ^([^.]+)$ $1.html [QSA]
 
        # Redirect all non-static requests to cluster
        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
        RewriteRule ^/(.*)$ balancer://mongrelcluster%{REQUEST_URI} [P,QSA,L]
 
 
        # Deflate
        AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
</VirtualHost>

301 Redirect

Problemas de mover páginas e URL canônicas….

.htaccess

Páginas

redirect 301 /antigo/endereco.htm http:www.novo.com/endereco.htm * Primeiro endereço sem “http:

Site inteiro

redirect 301 / http:www.you.com/ ===== URL canônica ===== Problema: Se seu site é acessado por www.site.com e site.com, vc pode ser indexado duas vezes.. entre outros dilemas…. Solução: == Com WWW == <code> Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^yoursite.com [NC] RewriteRule ^(.*)$ http:www.yoursite.com/$1 [L,R=301] </code>

Sem WWW
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ yoursite.com/$1 [L,R=301]

source(s)

http:www.tamingthebeast.net/articles3/spiders-301-redirect.htm http:www.seobuzzbox.com/what-is-a-canonical-url/