I installed WP in subfolder /cms and it runs live without subfolder. When I use /%postname%/ as permalink I get 404 error on my site. My Server supported mod_rewrite.

My Code

wp-config.php

define('WP_SITEURL', 'http://www.sitename.de/cms');
define('WP_HOME', 'http://www.sitename.de');

root

1) .htaccess

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

2) index.php

<?php
define('WP_USE_THEMES', true);
require('./cms/wp-blog-header.php');
?>  

/cms

1) .htaccess

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

2) index.php

<?php
define('WP_USE_THEMES', true);
require('./wp-blog-header.php');
?>  

Thanks for your help
Ogni

4 Answers
4

What I generally do

  • Install WP in sub directory.
  • Open permalink set required permalink.
  • Open settings->general link
  • Remove the sub directory name from ‘Site Address (URL)’
  • Cut the index.php and .htaccess files from sub directory and paste them to root
  • change code in index.php as you did.
  • Again access settings->permalink save the form

Done. You dont need index.php and .htaccess file in sub directory.

Leave a Reply

Your email address will not be published. Required fields are marked *