5

I am running two ExpressionEngine sites on two different domain names using the MSM plugin. Site one has all the system files etc and site two is in a subfolder of site one. My question is how can I get site two to not have its index.php file in the url and still work?

Currently I have this in my htaccess folder of site one and site one works great, site two doesn't:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Removes index.php
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]

    DirectoryIndex index.html index.php

    # Redirect non-www urls to www
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    # If 404s, "No Input File" or every URL returns the same thing
    # make it /index.php?/$1 above (add the question mark)

Gareth
  • 307
  • 3
  • 8
  • 1
    Have you added the .htaccess file to site two as well? Assuming you have, in what way does it not work? E.g. is the homepage displayed for all requests? – Dom Stubbs Nov 05 '12 at 09:57

3 Answers3

3

The same .htaccess should work for both sites. The rewriting only involves the index.php file, which is local to each site's root.

One possible issue I see from your .htaccess is that you're redirecting non-www URLs to www. Is your second domain setup to work with www? If not, this would obviously be a problem.

Jeremy Gimbel
  • 371
  • 2
  • 5
  • Hi Jeremy, thanks for this. I got it working with the same htaccess file in both site roots as you suggest and I am not sure why it started working (I had not changed anything). When you say: Is your second domain setup to work with www? Do you mean within the EE control panel general config settings? – Gareth Nov 07 '12 at 09:13
1

I use this htaccess file on both primary and secondary sites and all is good.

AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm

AcceptPathInfo On

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On

Options +FollowSymLinks

# Looks for files and directories that do not exist
# and provide the segments to the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>  
Steven Grant
  • 1,236
  • 3
  • 15
  • 32
1

Try putting your # Redirect non-www urls to www rewrite before the # Removes index.php rewirte.

Having the www rewrite before the remove index.php rewrite has caused issues for me in the past and in a quick test of one of my sites, accessing the www-version when the www rewrite is placed before the remove index.php rewrite causes index.php not to be removed from the URL.

Alex Kendrick
  • 969
  • 9
  • 18
  • Thanks for this Alex I'll give that a try, I managed to get things working with the code as is, so I am not sure what I was doing wrong before. This is my first MSM site so I am still working my way through things. – Gareth Nov 07 '12 at 09:20