v2.36.0/Free plan includes 10 AI requests a day. No card needed.

Search and indexing

Edit .htaccess safely: tested before and after, undone if it breaks

Use the .htaccess editor for Apache and LiteSpeed: what is checked, how the live test and automatic rollback work, how to restore an earlier version, and when the editor is read-only.

Time

10 minutes

What you need

  • A site on Apache or LiteSpeed
  • A WordPress administrator login (a super admin on a network)
  • A recent backup

.htaccess holds redirects, caching and security rules for Apache and LiteSpeed. One wrong line shows a server error to every visitor. The editor in OnlyAI SEO checks your text, tests your site before and after, and puts the old file back automatically if anything breaks.

Open it

Go to OnlyAI SEO, Settings, .htaccess. If you do not see an editor, your server is not Apache or LiteSpeed (Nginx has no .htaccess; the same rules go in the server configuration), or your site has turned off file editing.

Make a change

  1. Edit the text. Put your rules above or below the # BEGIN WordPress block, never inside it: WordPress rewrites that block when permalinks are saved.
  2. Press Check only to see findings without saving.
  3. Press Check and save.

What happens when you save

  1. The text is checked. Refused: a file over 128 KB, PHP code, a block such as <IfModule> that is never closed or is closed by the wrong tag.
  2. Confirmation needed for risky things: no WordPress rewrite rules while pretty permalinks are on (posts would show "not found"), and a line that denies every visitor for the whole site.
  3. Your site is asked for its home page, newest post and login page before the change.
  4. The file is written, and the same three addresses are asked again.
  5. If any of them now breaks (a server error, a new 4xx, no answer, a redirect loop), the old file is put back at once and you are told which address broke.

When the site cannot test itself

Some hosts block a site from calling its own address. Then saving needs you to tick Save without the live check, and the result says it was saved without one.

Earlier versions

The last five versions are kept, with who saved them and when. Press Restore next to one under Earlier versions; it goes through the same check. A copy is also left beside the file as .htaccess.onlyai-backup.

Who can use it

  • Administrators on a single site. On a network, only super admins (the file is shared by every site).
  • It is read-only when your wp-config.php sets DISALLOW_FILE_EDIT or DISALLOW_FILE_MODS.
  • Having the plugin's own "manage" right is not enough: server rules can run code, so it is an administrator's job.

If the file is not writable the card says so: change the permissions (644 is usual) or ask your host.

Next

Stuck?

We answer every email

Write to [email protected] with a short description and your plugin version. Or browse all guides, the troubleshooting page and the docs.

Email usTroubleshootingAll guides

More in Search and indexing