Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: juanon on January 09, 2014, 19:37:44

Title: Testing multisites in local
Post by: juanon on January 09, 2014, 19:37:44
Hi,

I´m using WAMP for testing the cms in localhost.

For SEF I have change RewriteBase base to RewriteBase /mysite/

But I need to know how to change this for multisite to work:

RewriteRule ^multisite1/estia/inner.php estia/inner.php [L]
RewriteRule ^multisite1/inner.php(.*) inner.php [L]
RewriteRule ^multisite1/(.*) $1

Thank you very much
Title: Re: Testing multisites in local
Post by: datahell on January 10, 2014, 11:24:56
For the "mother site" (the 1st multi-site) you add nothing. You add rewrite rules only for the sub-sites.
Put the .htaccess file inside the Elxis root folder with RewriteBase /mysite/
I advise you not to use sub-folders but virtual hosts.

Multi-sites documentation (https://www.elxis.net/docs/using-elxis/administration/multisites.html) on Elxis Docs.
Elxis 4.x installation and virtual hosts setup video tutorial (http://www.youtube.com/watch?v=o3sq1yq2-ao) on youtube
Title: Re: Testing multisites in local
Post by: juanon on January 10, 2014, 12:08:33
Thanks datahell,

The main site is working ok, my problem is with second and third multisites:

this lines of code doesn´t work (I get a page not found message):

RewriteRule ^multisite1/estia/inner.php estia/inner.php [L]
RewriteRule ^multisite1/inner.php(.*) inner.php [L]
RewriteRule ^multisite1/(.*) $1

How can I change them to work?

For your information, in my list of subsites I have this urls
mysite           http://localhost/mysite
lsubsite1       http://localhost/subsite1

Thanks a lot


Title: Re: Testing multisites in local
Post by: datahell on January 10, 2014, 12:24:43
I believe that you have your Elxis main installation in sub-folder "mysite".
If this is how you see your main site:
http://localhost/mysite/
Then the sub-sites are available like this:
http://localhost/mysite/subsite1/
http://localhost/mysite/subsite2/
etc...

htaccess Rewrite base =  /mysite/ in this case

So, I guess your URLs are wrong...

If you have installed Elxis in web server root and you see it like this:
http://localhost/
Then the sub-sites are available like this:
http://localhost/subsite1/
http://localhost/subsite2/
etc...

htaccess Rewrite base =  / in this case
Title: Re: Testing multisites in local
Post by: juanon on January 10, 2014, 15:30:33
Thanks for your answer Datahell.

Perhaps it is an issue with multisites when Elxis is installed in a subfolder, can it be?

When I have created the subsite1 I get this in the multisites list:

mysite           http://localhost/mysite
subsite1       http://localhost/subsite1

Of course with the standard lines of code to include in .httpdocs it doesn´t work.

Regards

Title: Re: Testing multisites in local
Post by: datahell on January 10, 2014, 15:41:53
No, it is not a bug, you have wrong URL and wrong htaccess.
These are things you must set, not Elxis.
If you do it correctly Elxis multi-sites will work fine even if Elxis is installed inside a folder.
Title: Re: Testing multisites in local
Post by: juanon on January 10, 2014, 17:15:51
Please check this:

My site is installed using wamp at localhost/myelxis

My .htaccess contains this code:

##
# Elxis 4.x htaccess file
# Copyright (C) 2006-2012 Elxis.org. All rights reserved.
# License: http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Elxis CMS is a Free Software
##

# Uncomment the lines bellow to add support for HTML5 video and audio
# AddType video/ogg .ogm
# AddType video/ogg .ogv
# AddType video/ogg .ogg
# AddType video/webm .webm
# AddType audio/webm .weba
# AddType video/mp4 .mp4
# AddType video/x-m4v .m4v
AddType application/json .json

## Uncomment the following line, if it produces erors, comment it again
# Options -Indexes +FollowSymLinks

#
#  mod_rewrite in use
#

RewriteEngine On

# The following line tells the web server where your Elxis installation is located in relation
# to the web server root directory. By default this is set to the www root folder ( RewriteBase / ).
# If you have installed Elxis in a sub-folder then set this path properly.
# For example if your elxis site is accessible via this URL http://www.example.com/elxis/
# You should set: RewriteBase /elxis/

RewriteBase /myelxis/

#
# Rewrite rules for sample multisites appeared as sub-folders of the main site
# RewriteRule ^one/estia/inner.php estia/inner.php [L]
# RewriteRule ^one/inner.php(.*) inner.php [L]
# RewriteRule ^one/(.*) $1
# RewriteRule ^two/estia/inner.php estia/inner.php [L]
# RewriteRule ^two/inner.php(.*) inner.php [L]
# RewriteRule ^two/(.*) $1
#

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d




RewriteRule ^subsite1/estia/inner.php estia/inner.php [L]
RewriteRule ^subsite1/inner.php(.*) inner.php [L]
RewriteRule ^subsite1/(.*) $1





# If you have renamed the administration folder change "estia" to the name you have set.
RewriteRule ^estia/inner.php(.*) estia/inner.php [L]
RewriteRule ^estia/(.*) estia/index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

#
## Security rules. Comment them if they cause problems to your site
#
# Block out any script trying to base64_encode crap to send via URL
# This rule is commented because it may cause some Elxis features to not work!
# RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]



I have created a subsite (subsite1) and as a result I get this in multisites list:

1      myelxis               Yes    http://localhost/myelxis
2    subsite1    subsite1    Yes     http://localhost/subsite1

I have followed the steps of Elxis Documentation in elxis.net, What is wrong?

Thanks in advance
Title: Re: Testing multisites in local
Post by: datahell on January 10, 2014, 19:40:08
This is the third time I tell you the same thing, the URL of the sub-site is wrong!
The correct url is this:
http://localhost/myelxis/subsite1

Open config2.php and set the correct value for URL.
private $URL = 'http://localhost/myelxis/subsite1';
Title: Re: Testing multisites in local
Post by: webgift on January 10, 2014, 20:23:59
Yeap ;)
Title: Re: Testing multisites in local
Post by: juanon on January 10, 2014, 20:55:24
Sorry but I already have          private $URL = 'http://localhost/myelxis/subsite1';       in config2.php.

Title: Re: Testing multisites in local
Post by: juanon on January 10, 2014, 20:57:51
I can´t attache an image here, but this

1      myelxis               Yes    http://localhost/myelxis
2    subsite1    subsite1    Yes     http://localhost/subsite1


Is what appears in MULTISITES PAGE in ADMIN PANEL after creating the subsite and I thing that´s the problem "http://localhost/----------------------/subsite1"

THANKS
Title: Re: Testing multisites in local
Post by: Coldy on January 10, 2014, 21:48:03
I have the same problem with this with Xampp.
Created Multisite shows the link to localhost/multisite and not to localhost/elxis/multisite
Alle changes in the config2 and htaccess are ok.
Title: Re: Testing multisites in local
Post by: datahell on January 11, 2014, 10:00:51
As we have said several times installing Elxis inside a folder is not a good option.
Elxis is a major CMS that wants to be the king of the web, by installing it inside a folder you limit it.
I am going to check it now and I will reply in a few minutes.

EDIT
If you have installed Elxis in a sub-folder then Elxis can't determine the current sub-site as the folder name in the URL confuses it.
To solve this problem do this:
1. Open file includes/multiconfig.php

2. Find this:
foreach ($multisites as $id => $site) {
   if ($site['active'] == false) { continue; }
   if ($site['folder'] == $folder) { $multisite = $id; break; }
}
Add below:
if (($multisite == 1) && isset($p[1])) {
   foreach ($multisites as $id => $site) {
      if ($site['active'] == false) { continue; }
      if ($site['folder'] == $p[1]) { $multisite = $id; break; }
   }
}
Save the file and you are ready.

I don't add this change in Elxis release as I think this setup, Elxis in sub-folder + multi-sites is a bad idea. Off course its OK for your local sites. So just do this change on your local Elxis installation.
Title: Re: Testing multisites in local
Post by: Coldy on January 11, 2014, 12:26:40
datahell <- you are the best! ;D
Now it works fine at Xampp! Thank you!

Only the link in the ACP shows the wrong link (localhost/multisite) but when i call the multisite manually, it works.
I need this only for testing. On my live site, the elxis installation is in the root. I think there'll be no problem with the default settings.
Title: Re: Testing multisites in local
Post by: juanon on January 11, 2014, 14:17:12
Thanks, it works now.