# invoke rewrite engine
RewriteEngine On
RewriteBase /

Options -Indexes
<IfModule mod_negotiation.c>
	Options -MultiViews
</IfModule>

# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Redirect 400,401,403,404,500 to main website
ErrorDocument 400 https://www.cork49gv.com
ErrorDocument 401 https://www.cork49gv.com
ErrorDocument 403 https://www.cork49gv.com
ErrorDocument 404 https://www.cork49gv.com
ErrorDocument 500 https://www.cork49gv.com

# Specific redirections
RewriteRule ^index\.html$ / [L,R=301]
RewriteCond %{QUERY_STRING} ^page=2$
RewriteRule ^wines$ wines_page-2 [L,R=301,QSD]
RewriteCond %{QUERY_STRING} ^page=3$
RewriteRule ^wines$ wines_page-3 [L,R=301,QSD]
RewriteRule ^store/p1/2018_Belle_Glos_%27Clark_%26_Telephone%27_Pinot_Noir_-_Santa_Barbara%2C_California\.html$ store/p1/2018_Belle_Glos_-Clark_-_Telephone-_Pinot_Noir_-_Santa_Barbara-_California [L,R=301,QSD]
RewriteRule ^store/p10/2017_Canyon_Road_Chardonnay_-_Sonoma_County%2C_California\.html$ store/p10/2017_Canyon_Road_Chardonnay_-_Sonoma_County-_California [L,R=301,QSD]
RewriteRule ^store/p12/2015_August_Briggs_Dijon_Clones_Pinot_Noir_-_Sonoma_County%2C_California\.html$ store/p12/2015_August_Briggs_Dijon_Clones_Pinot_Noir_-_Sonoma_County-_California [L,R=301,QSD]
RewriteRule ^store/p13/2016_Domaine_Philippe_Goulley_Chablis_Premier_Cru_%27Montmains%27_-_France\.html$ store/p13/2016_Domaine_Philippe_Goulley_Chablis_Premier_Cru_-Montmains-_-_France [L,R=301,QSD]
RewriteRule ^store/p14/2018_Kenwood_Six_Ridges_Russian_River_Valley_Chardonnay_-_Sonoma_County%2C_California\.html$ store/p14/2018_Kenwood_Six_Ridges_Russian_River_Valley_Chardonnay_-_Sonoma_County-_California [L,R=301,QSD]
RewriteRule ^store/p15/2018_Villarini_Nero_d%E2%80%99Avola_Organic_-_Italy\.html$ store/p15/2018_Villarini_Nero_d-Avola_Organic_-_Italy [L,R=301,QSD]
RewriteRule ^store/p17/2018_Belle_Glos_%27Las_Alturas%27_Pinot_Noir_-_Monterey%2C_California\.html$ store/p17/2018_Belle_Glos_-Las_Alturas-_Pinot_Noir_-_Monterey-_California [L,R=301,QSD]
RewriteRule ^store/p19/2017_Murrieta%27s_Well_%27The_Whip%27_White_Wine_Blend_-_Livermore_Valley%2C_California\.html$ store/p19/2017_Murrieta-s_Well_-The_Whip-_White_Wine_Blend_-_Livermore_Valley-_California [L,R=301,QSD]
RewriteRule ^store/p2/2017_Vina_Robles_Estate_Cabernet_Sauvignon_-_Paso_Robles%2C_California\.html$ store/p2/2017_Vina_Robles_Estate_Cabernet_Sauvignon_-_Paso_Robles-_California [L,R=301,QSD]
RewriteRule ^store/p20/2016_Stag%27s_Leap_Merlot_-_Napa_Valley%2C_California\.html$ store/p20/2016_Stag-s_Leap_Merlot_-_Napa_Valley-_California [L,R=301,QSD]
RewriteRule ^store/p21/2016_Armeda_Winery_Poizin_Zinfandel_-_Sonoma%2C_California_\.html$ store/p21/2016_Armeda_Winery_Poizin_Zinfandel_-_Sonoma-_California_ [L,R=301,QSD]
RewriteRule ^store/p22/2018_Oak_Farm_Sauvignon_Blanc_-_Lodi%2C_California\.html$ store/p22/2018_Oak_Farm_Sauvignon_Blanc_-_Lodi-_California [L,R=301,QSD]
RewriteRule ^store/p24/Stanford_Brut_Governer%27s_Cuvee\.html$ store/p24/Stanford_Brut_Governer-s_Cuvee [L,R=301,QSD]
RewriteRule ^store/p25/2018_Bella_Grace_Estate_Bella_Ros%C3%A9_-_Amador_County%2C_California\.html$ store/p25/2018_Bella_Grace_Estate_Bella_Rosé_-_Amador_County-_California [L,R=301,QSD]
RewriteRule ^store/p26/2017_Cycles_Gladiator_Petite_Sirah_-_Lodi%2C_California\.html$ store/p26/2017_Cycles_Gladiator_Petite_Sirah_-_Lodi-_California [L,R=301,QSD]
RewriteRule ^store/p27/2017_Orin_Swift_Machete_Red_Blend_-_Napa%2C_California\.html$ store/p27/2017_Orin_Swift_Machete_Red_Blend_-_Napa-_California [L,R=301,QSD]
RewriteRule ^store/p28/2016_Tooth_%26_Nail_The_Possessor_Red_Blend_-_Paso_Robles%2C_California\.html$ store/p28/2016_Tooth_-_Nail_The_Possessor_Red_Blend_-_Paso_Robles-_California [L,R=301,QSD]
RewriteRule ^store/p29/2016_Domaine_la_Garrigue_%22Cuv%C3%A9e_Romaine%22_C%C3%B4tes_du_Rh%C3%B4ne_-_France\.html$ store/p29/2016_Domaine_la_Garrigue_-Cuvée_Romaine-_Côtes_du_Rhône_-_France [L,R=301,QSD]
RewriteRule ^store/p3/2016_Rabble_Red_Blend_-_Paso_Robles%2C_California\.html$ store/p3/2016_Rabble_Red_Blend_-_Paso_Robles-_California [L,R=301,QSD]
RewriteRule ^store/p30/2015_Domaine_la_Garrigue_Vacqueyras_%22La_Cantarelle%22_-_France\.html$ store/p30/2015_Domaine_la_Garrigue_Vacqueyras_-La_Cantarelle-_-_France [L,R=301,QSD]
RewriteRule ^store/p32/2016_Dueling_Pistols_Dry_Creek_Valley_Red_Blend_-_Sonoma_County%2C_California\.html$ store/p32/2016_Dueling_Pistols_Dry_Creek_Valley_Red_Blend_-_Sonoma_County-_California [L,R=301,QSD]
RewriteRule ^store/p33/2017_DAOU_Vineyards_Bodyguard_-_Paso_Robles%2C_California\.html$ store/p33/2017_DAOU_Vineyards_Bodyguard_-_Paso_Robles-_California [L,R=301,QSD]
RewriteRule ^store/p36/2016_Rutherford_Hill_Barrel_Select_-_Napa_Valley%2C_California\.html$ store/p36/2016_Rutherford_Hill_Barrel_Select_-_Napa_Valley-_California [L,R=301,QSD]
RewriteRule ^store/p4/2017_Carpineto_Dogajolo_Toscano%2C_IGT_-_Italy\.html$ store/p4/2017_Carpineto_Dogajolo_Toscano-_IGT_-_Italy [L,R=301,QSD]
RewriteRule ^store/p5/2018_Mountain_Ranch_Winery_Grand_Reserve_Old_Vine_Barbera_-_Sierra_Foothills%2C_California\.html$ store/p5/2018_Mountain_Ranch_Winery_Grand_Reserve_Old_Vine_Barbera_-_Sierra_Foothills-_California [L,R=301,QSD]
RewriteRule ^store/p8/2016_Ch%C3%A2teau_de_Plaisance_%E2%80%9CEmbruns%E2%80%9D_Chenin_Blanc_Anjou_-_France\.html$ store/p8/2016_Château_de_Plaisance_-Embruns-_Chenin_Blanc_Anjou_-_France [L,R=301,QSD]
RewriteRule ^store/p9/2016_Penfolds_Max%27s_Cabernet_Sauvignon_-_South_Australia\.html$ store/p9/2016_Penfolds_Max-s_Cabernet_Sauvignon_-_South_Australia [L,R=301,QSD]

# Create pretty URLs
DirectorySlash Off

RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ %1 [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)/$
RewriteRule ^(.*)/$ $1 [NC,L,R=301]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
# End: Create pretty URLs

# Redirect all extensions to html
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.shtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.phtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jhtml$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.htm$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.php$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.aspx$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.asp$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.jsp$ $1.html [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)\.apk$ $1.html [L,NC,R=301]
# End: Redirect all extensions to html
