eZ Community » Forums » Install & configuration » Problem of migration/url redirections...

Problem of migration/url redirections to another server with a root directory

Problem of migration/url redirections to another server with a root directory

Monday 30 March 2015 4:05:56 pm - 6 replies

Hello everybody, 

I'm new with ezpublish and i want to migrate a website 4.3 to another server with a root directory but i have problems with url and the subfolder.

I modified the SiteURL site.ini.append.php files in settings/override and settings/siteaccess/admin and i have well access to the site and all anothers pages but i can't login to the admin page with, and other form redirections don't work too.

Old site : www.xxx.com/

New site : www.yyy.com/zzz/ In form cases and admin forms, it redirects me to www.yyy.com/ and not to the zzz subfolder....

I try to modify the .htaccess but i don't find the solution...

in .htaccess file

RewriteEngine On
RewriteBase /yyy
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
DirectoryIndex index.php

Someone can help me please ?

Thanks, Alex.

Modified on Monday 30 March 2015 4:54:10 pm by Alexis Gomez

Tuesday 31 March 2015 7:15:38 am

Hello Alexis,

Your use of eZ Publish within a subdirectory is supported and should work. I think the key to getting this to work is found in the correct ini settings and mod_rewrite rules.

I'm unclear why you think you need to use RewriteBase and in general you should not use the mod_rewrite rules you shared.

You should use the .htaccess mod_rewrite rules provided by default in eZ Publish Legacy. Here is an example: https://github.com/ezsystems/ezpublish-legacy/blob/stable-4.3/.htaccess_root

Can you share your settings/override/site.ini.append.php, settings/siteaccess/admin/site.ini.append.php and settings/siteaccess/(custom-user-siteaccess-name)/site.ini.append.php settings in a Gist here in the forum thread?

When you share these settings via Gist here in the forums, we should be able to make more specific recommendations on what ini changes you should make to ensure the problem is solved correctly.

I hope this helps!


Modified on Tuesday 31 March 2015 10:11:33 am by // Heath

Tuesday 31 March 2015 11:08:36 am

Hello Heath,

I used the .htaccess mod_rewrite rules provided by default in eZ Publish Legacy as you told me but nothing changed, besides i have a "forbidden" page when i try to access to other pages than the main. Even if i change the following "Files" section with the subdirectory of my installation it doesn't work, thus i allow from all in <FilesMatch ".">. 

I tried to use a RewriteBase to redirect form submissions to my subdirectory but it doesn't work.


The solution below...

Modified on Tuesday 31 March 2015 2:29:32 pm by Alexis Gomez

Tuesday 31 March 2015 12:42:53 pm

Ok Heath, i have found the solution, in fact, it's a cache issue ! 

But I do not know exactly what to delete cache files !

I have two cache directories :

var -> cache

var -> mysite -> cache -> codepages

                                -> ezmutex

                                -> override

                                -> packages

                                -> rss

                                -> template

                                -> template-block

                                -> trans

                                -> translation

                                -> user-info

                                -> wildcard

Or should I remove all cache before importing the site files ?  

If i delete the template directory, i don't have the template for admin page and all contents in other pages are deleted ??

Modified on Tuesday 31 March 2015 2:28:15 pm by Alexis Gomez

Tuesday 31 March 2015 5:13:11 pm

Hello Alexis,

The cache, var/cache/* and var/mysite/cache/* directory contents (all contents; dirs and files) will be recreated upon the next web request to the website.

Remember that the contents of the cache directory are basically compiled copies of the resources which make up your site (ini settings, database content, compiled templates, etc) but not the actual / real resources required to power your site, merely a cached copy which is always safe to remove.

Be certain your webserver user and group has the required permissions to write to the var directory (recursive permissions) so it can create / recreate the required cache contents.

You should not hesitate to clear the cache by hand (manually) or using the bin/php/ezcache.php command line script, https://github.com/ezsystems/ezpublish-legacy/blob/stable-4.3/bin/php/ezcache.php#L47

I regularly run the following commands to clear all caches in eZ Publish: cd /path/to/ezpublish; php ./bin/php/ezcache.php --clear-all;

If you have problems after clearing cache please understand you need to face those problems head on and solve them as well in order for your migration / setup / website to be configured properly on the new host. You do not want to avoid clearing all caches because you have problems after removing it.

Regarding your previous message about .htaccess rules ... are you having trouble accessing other pages provided through eZ Publish other than the index page .. or other pages that are separate from eZ Publish but contained with your eZ Publish root directory (what you called, 'zzz')? The answer will determine what changes need to be made.

For now I will continue .. on some less than perfect hosting providers I have also encountered with using the default .htaccess rules. It has been a very long time since I had to troubleshoot such problems but I would suggest trying the following as seeing what results you get.

Try commenting out this first FilesMatch directive block entirely, https://github.com/ezsystems/ezpublish-legacy/blob/stable-4.3/.htaccess_root#L5

Test carefully, fully end your web browser, clear all caches (jik, ezp & web browser) and see if that does not solve the problem you describe (accessing eZ Publish based pages other than the index page).

If it does not, while I hesitate to use this next suggestion in production, you might also want to test commenting out the second FilesMatch directive block entirely, https://github.com/ezsystems/ezpublish-legacy/blob/stable-4.3/.htaccess_root#L10

Again, test carefully, fully end your web browser, clear all caches (jik, ezp & web browser) and see if that does not solve the problem you describe (accessing eZ Publish based pages other than the index page).

If any of the following works or works better than previously consider asking your hosting for more specific support with regards to this problem as these FilesMatch directive blocks are designed to secure access to the website through eZ Publish directly and deny access to any other files contained within the ezpublish root directory as this is normally a serious security problem. IE: Prevents direct access to ini settings files. Apologies for not being able, at this time, to give you a better example solution you can just copy and paste within this regard. 

Not sure if I need to mention it but you absolutely should not have any need to rely on the RewriteBase mod_rewrite configuration usage you shared. It's just not the 'right' solution to whatever problems you may still have at this point.

One more point to remember. I saw your first edit when you shared the requested settings and noticed one thing ... If your using the default mod_rewrite rules of eZ Publish you do not need or want to use the string index.php in your siteaccess site.ini.append.php [SiteSettings] SiteURL and SiteAdminURL settings as this could cause you problems, is unnecessary, ugly and not user or seo friendly.

When the default mod_rewrite rules are being used all requests are forced to go through the index.php file automatically (with some exceptions like design resources, var directory content ie: uploaded images, etc).

Note: The reason you may have had problems pasting your settings in the forum message body is because in general you should instead use the provided forum message editor's toolbar literal text feature to share code snippets within the colored box added to the forum message (after code type selection). Like I requested, using a Gist is much simpler as an alternative to consider in the future.

I hope this helps!


Wednesday 01 April 2015 11:06:17 am

Hi Health,

First, thank you very much for all the explanations.

I well understand for the cache but the problem is that when i want to clear all the cache by hand (manually) or into the panel admin control, after i have no more templates for admin panel and no more contents in my site, all articles and images are no longer visibles in my admin panel and website !!? Everything disappears and i have no more control in admin like simply create a page content !!! And i don't understand this phenomenom !  

Before copying the files and make the migration, I did not clear the cache, this affects you it ? And in my var/mysite/cache/compiled i have more of 18'000 files, it's normal ?

I saw after for the gist code snippets button to share and it's true that it's much easier ! I posted my two settings site.ini.append.php files but i deleted after because i didn't think that was the problem, here they are :


'zzz' corresponds to my new subdirectory.

I have access at all the pages even the admin control, but i can't create new page content in admin and i can't submit all forms in admin or website because when i click to submit, my subdirectory is not taken into account !!

http://mysite/subdir/ ok

http://mysite/subdir/any-page ok

With a login form or link for example, it redirects me to http://mysite/user/login instead of http://mysite/subdir/user/login

Finally, I wonder if i well made the migration, i moved all server files in the new server and export by hand the sql database from phpmyadmin to the new, it seems normal to me but that is the right procedure ?

Modified on Wednesday 01 April 2015 12:15:00 pm by Alexis Gomez

Wednesday 01 April 2015 2:41:24 pm

Hello Alexis,

Big reply, this will take a few minutes to break down piece by piece.

Regarding problems after clearing cache ...

To your question about clearing caches before a migration, The answer is Yes this is to many considered a best practice.

Your templates / design elements / etc again are separate from cache. Enable eZ DebugOutput. Tail the var/log/error.log. And probably for good measure enable php's display_errors On feature. You need to clear all caches. Then reload the webpage and fix the errors reported.

Since this is a new host. There is also the very real posiblity that the host does not provide for eZ Publish requirements. Consider enabling the setup wizard via settings/override/site.ini.append.php [SiteAccessSettings] CheckValidity=true clearing ini caches and loading the website and going through the first two pages of requirements tests to ensure the requirements are right; ps if you just use the first two pages of the setup wizard you do not need to do the complete setup, then just disable it changing CheckValidity=false.

Regarding images missing, often ImageMagick is not installed or available on a new host. This is checked using the setup wizard.

You say, "And in my var/mysite/cache/compiled i have more of 18'000 files, it's normal ?" I've seen 40GB+ of cache in the past. The amount is not really a serious concern per-say. I would ignore your concern, this is how the system works.

Thank you for sharing your settings again this time via Gist! You even figured out how to embed it in the forum post, Good Job!

In the setting file, 'settings/override/site.ini.append.php' you should make the following changes:

  • Change, '[SiteAccessSettings] ForceVirtualHost=true' to '[SiteAccessSettings] ForceVirtualHost=false'
  • Change, 'MatchOrder=uri;host' to 'MatchOrder=uri'
  • Remove index.php string from your user siteaccess site.ini.append.php [SiteSettings] SiteURL and SiteAdminURL 

Doing the above will generate some solutions and many more issues for you to solve. Doing this work can / will help solve your problems long term.

In short ForceVirtualHost=true was why your forms were redirecting as you describe, or at least part of it.

You need to see php errors, because i'm almost certain your generating a lot and not knowing you need to fix them.

What version of PHP are you using on the new host? It also sounds like you may require an upgrade of eZ Publish for the site to run on the new host which most likely has a newer version of PHP.

Feel free to ask more questions! Run the setup wizard first so you can assess your core server problems in eZ then share the results here in the forums to discuss!

I hope this helps!



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from