Search code examples
wordpressapache.htaccessmod-rewrite

Wordpress post page get 404 but Homepage works


I already red a lot about this problem, but non of the solutions helped me out. I installed a fresh Wordpress on my Apache. After changing the permalink structure from default (www.domain.com/?p=id) to another one, wordpress delivers me an 404 error for each page except the homepage.

I already checked the following:

  • mod_rewrite is installed and enabled (checked through phpinfo)
  • .htaccess is read- and writable

Here is my default .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Using the plugin "Debug this", I could also find out, that the rewrite rule always deliveres additional index.php? at the beginning. E.g. sitemap_index\.xml$ is rewrited as index.php?sitemap=1

What can I do so solve the problem? Default links like www.domain.com/?p=1 but that kills all my SEO.

Edit: After the installation, there was also /index.php/%postname% written in the custom permalink. But this setting is also returning a 404.


Solution

  • open this file

    /etc/apache2/apache2.conf
    

    chnage all AllowOverride None to AllowOverride All and restart your apache after that update your permalink structure to post and update it.

    path can be different from "/etc/apache2/apache2.conf"