htaccess configuration with multiple domains, subfolders, wordpress index.php

I am really struggling with an .htaccess issue and getting WordPress pretty permalinks to work, and remove index.php. My webserver has the following directories:

webroot
   -mydomain1 [wordpress folder]
   -mydomain2
   -mydomain3

In my webroot I have the following .htaccess file in the root with the following code. This redirect works just fine and points each domain to the relevant subfolder.

Read More
#Turns the rewrite engine on.
RewriteEngine on

#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

#www.mydomain1.ca and mydomain1.ca will map to the folder
{root}/mydomain1/
 RewriteCond %{HTTP:Host} ^(?:www.)?mydomain1.ca$
 RewriteRule (.*) /mydomain1/$1 [NC,L,NS]

#www.mydomain2.com and mydomain2.com will map to the folder
{root}/mydomain2/
 RewriteCond %{HTTP:Host} ^(?:www.)?mydomain2.com$
 RewriteRule (.*) /mydomain2/$1 [NC,L,NS]

#www.mydomain3.com and mydomain3.com will map to the folder
{root}/mydomain3/
 RewriteCond %{HTTP:Host} ^(?:www.)?mydomain3.com$
 RewriteRule (.*) /mydomain3/$1 [NC,L,NS]

#subdomain.domain.com will map to the folder {root}/folder3/
 RewriteCond %{HTTP:Host} ^(?:subdomain.domain.com)?$
 RewriteRule (.*) /folder3/$1 [NC,L,NS]

In the wordpress directory (mydomain1) I have been trying to place the standard WordPress .htaccess file. I was hoping this would remove the index.php from the URLs served up my WordPress. When I put this file into the wordpress directory and setup up the WordPress permalinks to /%postname%/ i get 404 errors and no pages. The .htaccess file I am trying to use here is:

# 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

I have talked to my hosting provider and they support mod_rewrite and subs and dont seem to be able to help. I have also gone into wordpress and set the permalinks to /%postname%/
The result of all of this is that I cannot access the site anymore. Can anyone help me please – I am reading all sorts of useful tips and tricks but with nothing seeming to help or work.

Related posts

Leave a Reply

1 comment

  1. Try removing this line :

    RewriteBase /
    

    If WordPress lives in a subfolder (and not on a virtualhost root directory), don’t use RewriteBase or set it to :

    RewriteBase /wordpress-folder/