3

We're working on a site that has Wordpress installed as the main CMS. EE is installed in subdirectory, and I am wanting to remove index.php. Everything I have tried removes both index.php and the subdirectory, but I need that subdirectory to stay in place, so WP will leave it alone.

So an address like: site.com/EE_subdirectory/index.php/site/page-url

Needs to change to: site.com/EE_subdirectory/site/page-url

I tried this .htaccess to my EE subdirectory:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

But it took out both the subdirectory and index.php. Do I need to do something to the WP .htaccess instead? Any ideas?

3 Answers 3

1

The documented approach to running EE from a subdirectory rather than the root, is to just remove the slash preceding index.php like so…

RewriteRule ^(.*)$ index.php/$1 [L]

Further, the documentation notes you might have to specify the sub-directory depending on your server config, so try this…

RewriteRule (.*?)index\.php/*(.*) EE_subdirectory/$1$2 [R=301,NE,L]

I’m also going to note that I suggest these rules should be in your (as you call it) WP .htaccess file, i.e. the one .htaccess file at the web root.

1
  • this seems sound too, however bear in mind that WP controls its .htaccess file. Changing the permalink settings in WP Admin could overwrite your .htaccess, making management of the sub site more tricky, just a point to remember!
    – Blatant
    May 8, 2015 at 16:25
0

Please try this in EE_subdirectory/.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine On
    RewriteBase /
    RewriteCond $1 !^(index\.php) [NC]
    RewriteRule ^(.*)$ /EE_subdirectory/index.php/$1 [L]
</IfModule> 
1
  • Sorry, that didn't work. The url's didn't change, and it blocked some of the content from loading. Feb 9, 2015 at 23:15
0

It might help if you post your WP htaccess as well if possible.

Your EE .htaccess looks a bit different to the 'copy and paste' version we use on many production sites, I'm not saying it's wrong just different! Here's a copy of our standard fare (i've altered to match your needs):

# Enable Rewrite Engine
<IfModule mod_rewrite.c>

    #Go go gadget
    RewriteEngine On
    RewriteBase /

    #Exclude file paths, directory paths
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$

    #file whitelist, do not rewrite if file is root & name is ...
    RewriteCond $1 !^(favicon\.ico|index\.php|path\.php|php\.ini|admin\.php) [NC]

    #directory whitelist, do not rewrite if path begines with ...
    RewriteCond $1 !^(system|sysbase|images|themes|css|assets)/ [NC]

    #Rewrite what needs rewriting
    RewriteRule ^(.*)$ /EE_subdirectory/index.php/$1 [L]

</IfModule>

Also, you have set your base URL (Admin -> General Configuration) in the CP with the subdirectory and the index.php to blank right? this will help EE serve proper links (once you get there!)

Give that a go and if it doesn't work share your WP .htaccess in case thats playing with the request URL before the EE .htaccess gets to it...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.