github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/htaccessFiles/.htaccess4 (about)

     1  ## REWRITE DEFAULTS
     2  RewriteEngine On
     3  RewriteBase /
     4  
     5  ## REQUIRE SUBDOMAIN
     6  RewriteCond %{HTTP_HOST} !^$
     7  RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
     8  RewriteRule ^/(.*)$ https://www.askapache.com/$1 [L,R=301]
     9  
    10  ## SEO REWRITES
    11  RewriteRule ^(.*)/ve/(.*)$ $1/voluntary-employee/$2 [L,R=301]
    12  RewriteRule ^(.*)/hsa/(.*)$ $1/health-saving-account/$2 [L,R=301]
    13  
    14  ## WORDPRESS
    15  RewriteCond %{REQUEST_FILENAME} !-f  # Existing File
    16  RewriteCond %{REQUEST_FILENAME} !-d  # Existing Directory
    17  RewriteRule . /index.php [L]
    18  
    19  ## ALTERNATIVE ANTI-HOTLINKING
    20  RewriteCond %{HTTP_REFERER} !^$
    21  RewriteCond %{HTTP_REFERER} !^https://(www\.)?askapache\.com/.*$ [NC]
    22  RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ - [F]
    23  
    24  ## REDIRECT HOTLINKERS
    25  RewriteCond %{HTTP_REFERER} !^$
    26  RewriteCond %{HTTP_REFERER} !^https://(www\.)?askapache\.com/.*$ [NC]
    27  RewriteRule ^.*\.(bmp|tif|gif|jpg|jpeg|jpe|png)$ https://google.com [R]
    28  
    29  ## DENY REQUEST BASED ON REQUEST METHOD
    30  RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)$ [NC]
    31  RewriteRule ^.*$ - [F]
    32  
    33  ## REDIRECT UPLOADS
    34  RewriteCond %{REQUEST_METHOD} ^(PUT|POST)$ [NC]
    35  RewriteRule ^(.*)$ /cgi-bin/form-upload-processor.cgi?p=$1 [L,QSA]
    36  
    37  ## REQUIRE SSL EVEN WHEN MOD_SSL IS NOT LOADED
    38  RewriteCond %{HTTPS} !=on [NC]
    39  RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
    40  
    41  ### ALTERNATATIVE TO USING ERRORDOCUMENT
    42  # https://www.htaccesselite.com/d/htaccess-errordocument-examples-vt11.html
    43  RewriteCond %{REQUEST_FILENAME} !-f
    44  RewriteCond %{REQUEST_FILENAME} !-d
    45  RewriteRule ^.*$ /error.php [L]
    46  
    47  ## SEO REDIRECTS
    48  Redirect 301 /2006/oldfile.html https://www.askapache.com/newfile.html
    49  RedirectMatch 301 /o/(.*)$ https://www.askapache.com/s/dl/$1