# Reset WordPress permalinks
Source: https://docs.webgee.com/en/hosting/wordpress/how-to-reset-your-wordpress-permalinks



When every page except the home page returns **404 Not Found**, the rewrite
rules in `.htaccess` are wrong or missing. Regenerating them fixes it. Applies
to all shared and reseller hosting.

This is the classic symptom after a migration, a restore, or an edit to
`.htaccess` that removed the WordPress block.

## From the WordPress dashboard [#from-the-wordpress-dashboard]

WordPress rewrites `.htaccess` whenever you save the permalink settings, so
saving twice regenerates the rules without changing anything.

1. Log in to the WordPress dashboard.
2. Go to **Settings** → **Permalinks**.
3. **Note the setting currently selected.** If it is **Custom Structure**, copy
   the string somewhere safe first.
4. Select **Plain**, then **Save Changes**. If Plain was already selected,
   choose **Day and name** instead. You should see *Permalink structure
   updated*.
5. Select your original setting again and **Save Changes**. Wait for the second
   *Permalink structure updated* message.

Clear your browser cache before testing, and test in a private window — a
cached 404 will otherwise convince you nothing changed.

## If you cannot log in [#if-you-cannot-log-in]

Replace the WordPress block in `.htaccess` by hand. The file is in your document
root, normally `public_html`, alongside `wp-admin` and `wp-config.php`.

Use cPanel's **File Manager** with **Show Hidden Files** enabled, or an FTP
client.

```apache
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
```

<Callout type="warn">
  Replace only the block between `# BEGIN WordPress` and `# END WordPress`.
  Overwriting the whole file discards anything else in it — redirects, security
  rules, caching directives and settings added by plugins.
</Callout>

If the file has no WordPress block at all, add this one at the top.

Once you can log in again, save the permalink settings from the dashboard so
WordPress owns the rules.

## If it does not help [#if-it-does-not-help]

* **A single page 404s, the rest work.** That is not a permalinks problem —
  check the page exists and is published.
* **`.htaccess` will not save.** Check the file's permissions; it should be
  `644`. See
  [Fix "Unable to create directory"](/en/hosting/wordpress/resolving-the-unable-to-create-directory-error-in-wordpress).
* **The site is in a subdirectory.** `RewriteBase` must match — `/blog/` rather
  than `/` for a site at `example.com/blog`.

## Related [#related]

* [Fix "Unable to create directory"](/en/hosting/wordpress/resolving-the-unable-to-create-directory-error-in-wordpress)
* [Enable WP\_DEBUG](/en/hosting/wordpress/how-to-view-enable-and-view-errors-on-a-wordpress-installation-wp-debug)
