ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Redirect to subfolders with htaccess

May 07, 2012 3:16pm

Subscribe [2]
  • #1 / May 07, 2012 3:16pm

    pushloop

    422 posts

    Hey guys

    I’m having some trouble with htaccess-settings for a MSM, multi-language site that’s been moved from a development site to a live server.

    The server setup looks like this

    site1/index.php <- This is the main site
    site1/site2/index.php <- This is the new site
    site1/site2/en/index.php <- This is the language folder for the new site

    Now, I’m forced to redirect site2.com using htaccess from site1 to site2. For this I’m using the following htaccess-file in site1:

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

    However, as soon as I try to access a subfolder, such as site1/site2/en/, this is being treated as an EE segment (by site2) and renders my EE 404 page.

    Would appreciate some help by any htaccess-guru out there!

    /André

  • #2 / May 08, 2012 2:06pm

    pushloop

    422 posts

    Well, I’ve made some progress. I’ve tested the following code:

    RewriteCond %{HTTP_HOST} ^(www.)?site2.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/site2/
    RewriteRule ^(.*)$ /popomax/$1
    RewriteCond %{HTTP_HOST} ^(www.)?site2.com$ [NC]
    RewriteRule ^(/)?$ site2/index.php [L]

    This seems to handle the basic redirect properly, and also works for other sub folders - except if the sub folder has the same name as a sub folder in the site root.

    I.e. the following setup is giving me a massive htaccess headache:

    /public_html/subfolder/
    /public_html/site2/subfolder/

    If I try to access http://www.site2.com/subfolder/ this renders /public_html/subfolder/ and not /public_html/site2/subfolder/


    Anyone know a way to handle this kind of redirect?

  • #3 / May 09, 2012 8:11am

    pushloop

    422 posts

    Problem solved. This turned out to be a hosting setup issue!

  • #4 / Jan 22, 2013 5:14am

    Maik Hoogkamer

    36 posts

    Pushloop, I am probably encountering the same problem. What hosting setup changes did you make?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases