#   *@=@=@=@ START LICENSE @=@=@=@*
#   Copyright or  or Copr. Stphane TRICHET and Nicolas SOTRON
#   
#   stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
#   
#   This software is a computer program whose purpose is to make a
#   web hosting platform
#   
#   This software is governed by the CeCILL  license under French law and
#   abiding by the rules of distribution of free software.  You can  use, 
#   modify and/ or redistribute the software under the terms of the CeCILL
#   license as circulated by CEA, CNRS and INRIA at the following URL
#   "http://www.cecill.info". 
#   
#   As a counterpart to the access to the source code and  rights to copy,
#   modify and redistribute granted by the license, users are provided only
#   with a limited warranty  and the software's author,  the holder of the
#   economic rights,  and the successive licensors  have only  limited
#   liability. 
#   
#   In this respect, the user's attention is drawn to the risks associated
#   with loading,  using,  modifying and/or developing or reproducing the
#   software by the user in light of its specific status of free software,
#   that may mean  that it is complicated to manipulate,  and  that  also
#   therefore means  that it is reserved for developers  and  experienced
#   professionals having in-depth computer knowledge. Users are therefore
#   encouraged to load and test the software's suitability as regards their
#   requirements in conditions enabling the security of their systems and/or 
#   data to be ensured and,  more generally, to use and operate it in the 
#   same conditions as regards security. 
#   
#   The fact that you are presently reading this means that you have had
#   knowledge of the CeCILL license and that you accept its terms.
#   *@=@=@=@ END   LICENSE @=@=@=@*



Options -Indexes
IndexIgnore *
RewriteEngine on


# on evite les robots autant que possible pour sauver de la bande passante
#RewriteCond %{HTTP_USER_AGENT} ^-?$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Advanced\ Email\ Extractor [NC,OR]
RewriteCond %{HTTP_USER_AGENT} almaden [NC,OR]
RewriteCond %{HTTP_USER_AGENT} @nonymouse [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Art-Online [NC,OR]
RewriteCond %{HTTP_USER_AGENT} CherryPicker [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Crescent\ Internet\ ToolPack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} DirectUpdate [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Download\ Accelerator [NC,OR]
RewriteCond %{HTTP_USER_AGENT} eCatch [NC,OR]
RewriteCond %{HTTP_USER_AGENT} echo\ extense [NC,OR]
RewriteCond %{HTTP_USER_AGENT} EmailCollector [NC,OR]
RewriteCond %{HTTP_USER_AGENT} EmailWolf [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ExtractorPro [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Fetch\ API\ Request [NC,OR]
RewriteCond %{HTTP_USER_AGENT} flashget [NC,OR]
RewriteCond %{HTTP_USER_AGENT} frontpage [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Go!Zilla [NC,OR]
RewriteCond %{HTTP_USER_AGENT} HTTP\ agent [NC,OR]
RewriteCond %{HTTP_USER_AGENT} HTTPConnect [NC,OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} IPiumBot\ laurion(dot)com [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Kapere [NC,OR]
RewriteCond %{HTTP_USER_AGENT} libwww-perl [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Microsoft\ URL\ Control [NC,OR]
RewriteCond %{HTTP_USER_AGENT} minibot\(NaverRobot\) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} NICErsPRO [NC,OR]
RewriteCond %{HTTP_USER_AGENT} NPBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Offline\ Explorer [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Offline\ Navigator [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Program\ Shareware [NC,OR]
RewriteCond %{HTTP_USER_AGENT} QuepasaCreep [NC,OR]
RewriteCond %{HTTP_USER_AGENT} SiteMapper [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Star\ Downloader [NC,OR]
RewriteCond %{HTTP_USER_AGENT} SurveyBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Teleport\ Pro [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Telesoft [NC,OR]
RewriteCond %{HTTP_USER_AGENT} TuringOS [NC,OR]
RewriteCond %{HTTP_USER_AGENT} TurnitinBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} vobsub [NC,OR]
RewriteCond %{HTTP_USER_AGENT} webbandit [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebCapture [NC,OR]
RewriteCond %{HTTP_USER_AGENT} webcollage [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebCopier [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebDAV [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebEmailExtractor [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebReaper [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WEBsaver [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebStripper [NC,OR]
RewriteCond %{HTTP_USER_AGENT} WebZIP [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Wget [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Wysigot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Zeus.*Webster [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Zeus [NC,OR]
RewriteCond %{HTTP_REFERER} ^XXX
RewriteRule ^.*$ - [F,L] 


#   <=<=<=< START HOSTS >=>=>=>
# PLICI/

#####
# Blocking the index listing
#####
#O#ptions -Indexes +FollowSymlinks
#I#ndexIgnore *

####
# Block the SVN and CVS fils (@TODO : a verifier)
####
<Files CVS> 
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
<Files .svn> 
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
<Files *.bak> 
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
<Files *.old> 
    Order allow,deny
    Deny from all
    Satisfy All
</Files>


#####
# set the PLICI error documents
#####
ErrorDocument 400 /view/error_doc/error.php?num=400
ErrorDocument 401 /view/error_doc/error.php?num=401
ErrorDocument 403 /view/error_doc/error.php?num=403
ErrorDocument 404 /view/error_doc/error.php?num=404
ErrorDocument 405 /view/error_doc/error.php?num=405
ErrorDocument 500 /view/error_doc/error.php?num=500

#####
# put on the rewrite Engine
#####
#R#ewriteEngine on
RewriteBase   /

#####
# if file already exist ignore
#####
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule "." - [L]


# the backoffice language
RewriteRule ^/?admin(s?_[^/]+)/l([0-9]+)/(.*)$     			admin$1/$3?c_l_a=$2  [QSA,N,L]

# the language
RewriteRule  ^/?l([0-9]+)/(.*)$     							$2?c_l_a=$1  [QSA,N,L]

# permit acces by /view/sites/my/site/
RewriteRule  ^/?view/sites/(my|for_plici)/[^/]+/(.*)$    		$2  [N,L]



#####
# Front Office rewriting rules
#####

# si c'est de l'admin on saute les 10 rgles du front
RewriteRule  ^/?admins?_[^/]+/ - [S=10]
	  # picture inherit /picture/ext/
	RewriteRule  ^/?picture/ext/(my|for_plici)/([^/]+)/(.+)$    	/view/sites/$1/$2/picture/$3 [QSA,L]

	  #direct by pass for the other images
	RewriteRule  \.(gif|png|jpe?g|ico)$ 						plici_rewriting.php [NC,L]
  
      # rewrite the url for page /
    RewriteRule  ^/?$ 											/core/entrees/front_sites/start_fo.php [L]
      
      # rewrite the url for page /index.html
    RewriteRule  ^/?index\.(html|php)?$ 							/core/entrees/front_sites/start_fo.php [L]
    RewriteRule  ^/?p([0-9]+)(_r([0-9]+))?-(.*)?$          		/core/entrees/front_sites/start_fo.php?plici_request_page_id=$1&product_id=$3  [QSA,L]
      
      # on en a besoin pour le tag phpmyvisites
    RewriteRule  ^/?stats/javascript\.js$    						/view/external_components/stats/phpmv2/phpmyvisites.js     [QSA,L]
    RewriteRule  ^/?stats/tag\.html$    							/core/entrees/front_sites/bypass.php?plici_bypass_for=/stats/tag.php    [QSA,L]
      
      # all bypassed script
    RewriteRule  ^/?([^/]+)\.html$       							/core/entrees/front_sites/bypass.php?plici_bypass_for=$1    [QSA,L]
    RewriteRule  ^/?js_([^/]+)\.js$    							/core/entrees/front_sites/bypass.php?plici_bypass_for=/js/$1.php    [QSA,L]
    RewriteRule  ^/?css_([^/]+)\.css$    							/core/entrees/front_sites/bypass.php?plici_bypass_for=/css/$1.php    [QSA,L]
      


#####
# Back Office rewriting rules
#####
# si c'est pas de l'admin on saute les 16 rgles du front
RewriteRule  !^/?admins?_[^/]+/ - [S=16]
      #-- For template (important must be on top)
    RewriteRule  ^/?admins?_[^/]+/he_tpl/(.+)$		     		/view/theme_rewriting/$1                     [QSA,L]
    RewriteRule  ^/?admins?_[^/]+/picture/([^/]+/)*([a-z_A-Z0-9]+)\.(jpeg|jpg|gif|png|ico)$    /view/sites/for_plici/admin_sites/picture/$1$2.$3     [QSA,L]
      #-- @TODO_PHPMV_UPDATE modifi cette ligne ce dessous(a reporter sur tous les autres sites)
    RewriteRule  ^/?admins?_[^/]+/p([A-Z_0-9]+)/stats/themes/(.*)$    /view/external_components/stats/phpmv2/themes/$2     [QSA,L]
    RewriteRule  ^/?admins?_[^/]+/p([A-Z_0-9]+)/stats/images/(.*)$    /view/external_components/stats/phpmv2/images/$2     [QSA,L]
    RewriteRule  ^/?admin_[^/]+/p([A-Z_0-9]+)/(.*)\.html$    			/core/entrees/admin_sites/$2.php?id_menu=$1     [QSA,L]
    RewriteRule  ^/?admin_[^/]+/css_([^/]+)\.css$    				/core/entrees/admin_sites/css/$1.php     [QSA,L]
    RewriteRule  ^/?admin_[^/]+/js_([^/]+)\.js$    				/core/entrees/admin_sites/js/$1.php     [QSA,L]
    RewriteRule  ^/?admin_[^/]+/css/([^/]+)\.htc$    				/core/entrees/admin_sites/css/$1.htc     [QSA,L]
      #-- rewrite the url for page /
    RewriteRule  ^/?(admins?_[^/]+)$ 								/$1/ [R]
    RewriteRule  ^/?admin_[^/]+/$ 								/core/entrees/admin_sites/index.php [QSA,L]
      #-- Fck editor
    RewriteRule  ^/?(admins?_[^/]+/)?html_editor/(.+)$    		/view/external_components/html_editor/$2     [QSA,L]
      
      
      #####
      # PLICI rewriting rules
      #####
    RewriteRule  ^/?admins_[^/]+/p([A-Z_0-9]+)/(.*)\.html$    		/core/entrees/admin_plici/$2.php?id_menu=$1     [QSA,L]
    RewriteRule  ^/?admins_[^/]+/css_([^/]+)\.css$    			/core/entrees/admin_plici/css/$1.php     [QSA,L]
    RewriteRule  ^/?admins_[^/]+/js_([^/]+)\.js$    				/core/entrees/admin_plici/js/$1.php     [QSA,L]
    RewriteRule  ^/?admins_[^/]+/css/([^/]+)\.htc$    			/core/entrees/admin_plici/css/$1.htc     [QSA,L]
    RewriteRule  ^/?admins_[^/]+/$ 								/core/entrees/admin_plici/index.php [QSA,L]

###
# -- Rewrite for BACK OFFICE and FRONT OFFICE
###
# -- Rewrite for internal module
RewriteRule  ^/?int_mod/(.*)$    												/view/module/$1     [QSA,L]

#####
# Activate redirect to the theme1 (now for picture)
#####
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule "." - [skip=10000]
RewriteRule  ^.*$     		plici_rewriting.php [L]

#   <=<=<=< END HOSTS >=>=>=>

