title: How to remove index.php from url without getting 404 error in wp?
body: <p>I know that this problem has been mentioned hundreds of times, and that there are hundreds of web pages and YouTube channels that have provided a solution, but I tried everything and it did not work, here is the information about this problem:
  1- WP Version 5.9.3</p>
  <p>2- PHP 8.1.4 (cli) (built: Apr 4 2022 13:30:17) (NTS)
  Copyright (c) The PHP Group
  Zend Engine v4.1.4, Copyright (c) Zend Technologies
  with Zend OPcache v8.1.4, Copyright (c), by Zend Technologies</p>
  <p>3-</p>
  <pre><code>$ sudo apache2ctl -t -D DUMP_MODULES
  Loaded Modules:
  core_module (static)
  so_module (static)
  watchdog_module (static)
  http_module (static)
  log_config_module (static)
  logio_module (static)
  version_module (static)
  unixd_module (static)
  access_compat_module (shared)
  alias_module (shared)
  auth_basic_module (shared)
  authn_core_module (shared)
  authn_file_module (shared)
  authz_core_module (shared)
  authz_host_module (shared)
  authz_user_module (shared)
  autoindex_module (shared)
  deflate_module (shared)
  dir_module (shared)
  env_module (shared)
  filter_module (shared)
  mime_module (shared)
  mpm_prefork_module (shared)
  negotiation_module (shared)
  php_module (shared)
  reqtimeout_module (shared)
  rewrite_module (shared)
  security2_module (shared)
  setenvif_module (shared)
  socache_shmcb_module (shared)
  ssl_module (shared)
  status_module (shared)
  unique_id_module (shared)
  </code></pre>
  <p>==================</p>
  <p>4- rewrite module:</p>
  <pre><code>$ sudo a2enmod rewrite
  Module rewrite already enabled
  </code></pre>
  <p>5-.htaccess:</p>
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  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]
  &lt;/IfModule&gt;
  </code></pre>
  <p>6- Woocommerce plugin installed</p>
  <p>7- Theme: Storefront</p>
  <p>==================================</p>
  <p>if I go Settings-&gt;Permalinks-&gt;Custom Structure: /index.php/%postname%/
  every thing is working except of the legacy API but this is not my problem now.
  if I go Settings-&gt;Permalinks-&gt;Custom Structure: /%postname%/
  I will get 404 error for all links in home page.</p>
  <p>==================================</p>
  <p>so please help me</p>