0
votes

I have a Wordpress install in a subdirectory of a Silverstripe install. I cannot get the front end of the Wordpress site to show due to the rewriting, however the back end works no problem if I append /index.php.

If I try append /index.php to /subdirectory/index.php it redirects back to subdirectory. There are no rules in the WP htaccess so I am thinking Silverstripe isn't liking the extensions.

I tried excluding the entire subdirectory folder by adding this to the Silvestripe site after Rewrite engine:

RewriteCond %{REQUEST_URI} !^/subdirectory/.* 

Not getting it right. Is there a way to allow 'subdirectory' to do its own thing?

2

2 Answers

1
votes

Rewrite rules apply to subfolders as well. If you don't have an .htaccess in your WP subfolder, you should create one and disable URL rewriting for that folder. So, put an .htaccess with the following content into your WP folder:

<IfModule mod_rewrite.c>
    RewriteEngine Off
</IfModule>

Of course you can also define custom rewrite rules… the important thing is, that you have your own .htaccess.

1
votes

You should have rules both in the SilverStripe root folder and in the WordPress folder, otherwise WordPress won't run without index.php. Something like this should work (although not 100% sure about the WordPress rules):

SilverStripe .htaccess

<IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On
    RewriteBase '/'

    RewriteCond %{REQUEST_URI} !^/wordpress/.*
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !\.php$
    RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>

Wordpress .htaccess in /wordpress folder

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