Search

I would like to have my symphony installation in a folder (say /cms), but I also would like that the URLs didn't have the /cms/, i.e., I want to use "my-domain.com" or "my-domain.com/xyz" instead of "my-domain.com/cms/" or "my-domain.com/cms/xyz".

Is it possible to do this?

A no B yes, with the extension root parameter

I think that extension doesn't solve my problem. I don't need parameters to my main page (in my example, xyz is a page).

Let me explain my question in a different way. I want to install symphony on '/cms/' folder in my website, but I would like to access my website with the same URLs I would use if I had installed symphony directly on '/' (root folder of the website).

All you will need to do is edit the htaccess file to forward your requests to the right place.

  1. Install Symphony the usual way in /cms folder.
  2. Once installed, move the .htaccess file into the root.
  3. Change the RewriteBase directive to / not /cms.
  4. Change the rewrite rules accordingly.

Here is how the .htaccess file should look after you've moved and edited it.

### Symphony 2.2.x ###
Options +FollowSymlinks -Indexes

<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteBase /

    ### SECURITY - Protect crucial files
    RewriteRule ^cms/manifest/(.*)$ - [F]
    RewriteRule ^cms/workspace/utilities/(.*).xsl$ - [F]
    RewriteRule ^cms/workspace/pages/(.*).xsl$ - [F]
    RewriteRule ^(.*).sql$ - [F]
    RewriteRule (^|/). - [F]

    ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
    RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
    RewriteRule .* - [S=14]

    ### IMAGE RULES
    RewriteRule ^image/(.+.(jpg|gif|jpeg|png|bmp))$ cms/extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC]

    ### CHECK FOR TRAILING SLASH - Will ignore files
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ $1/ [L,R=301]

    ### URL Correction
    RewriteRule ^cms/(symphony/)?index.php(/.*/?) $1$2 [NC]

    ### ADMIN REWRITE
    RewriteRule ^symphony/?$ cms/index.php?mode=administration&%{QUERY_STRING} [NC,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^symphony(/(.*/?))?$ cms/index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}   [NC,L]

    ### FRONTEND REWRITE - Will ignore files and folders
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/?)$ cms/index.php?symphony-page=$1&%{QUERY_STRING}    [L]

</IfModule>
######

This is not tested, but theoretically should work fine. Give it a go and let us know the outcome :)

Thanks designermonkey. It is partially working.

I also have to fix the internal links generated by Symphony. Any idea to fix this?

Additionally, the language redirect is not working properly. If I don't put the language code in the URL, the URL is not redirected. I did the following changes to the language redirect rules:

### LANGUAGE REDIRECT RULES start
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(pt|en)-?()?/(.*/?)$ cms/index.php?language=$1&region=$2&symphony-page=$3&%{QUERY_STRING} [L]
    ### LANGUAGE REDIRECT RULES end

Maybe if I fix the root url that symphony is using this is also fixed.

I think I know how to do this...

Just to check, can you add this to index.php under line 4

var_dump(DOCROOT, DOMAIN);die;

and post the output for me (while Symphony is installed in /cms)

If we can get this working, it would be good for a write up for the docs...

This is the output:

string(26) "/home/----/www/cms" string(15) "----.net/cms"

Hah, yes.

Ignore everything I've said so far, and return your .htaccess back to it's original layout (without the /cms changes). Leave it in the root directory though. Move the index.php file to the root and change lines 3 and 4 to the following, and it should sort out any problems you're having...

define('DOCROOT', dirname(__FILE__) . 'cms');
define('DOMAIN', rtrim($_SERVER['HTTP_HOST'], '\/'));

Let me know as this is very untested!

I did something similar with wordpress (spit) a while back and it worked.

Actually, just played with that and there are still hardcoded URLs at work, so it aint gonna work

Actually, none of this seems to work for me... Let me have a play and I'll get back to you...

Thanks designermonkey. If this is too complex, I can move my installation to the root directory. This would be useful to better organize my website, but I can move the installation.

It is complex, but I like a challenge...

In the index.php change the DOMAIN define to

define('DOMAIN', rtrim($_SERVER['HTTP_HOST'], '\/'));

in the .htaccess that I have given you, add the following just under the RewriteBase so it's the first rule

RewriteCond %{REQUEST_URI} symphony/assets/
RewriteRule ^(symphony/assets/.*) cms/$1 [L]

This should fix the admin and ensure that the front end functions correctly. This is only tested with the default installation, so I reckon you will definitely encounter issues down the line.

As for the language redirect, can you attach your .htaccess with the rules in place (zip and attach), I think the forum fracked it slightly as the rules displayed don't make sense as redirects.

...Getting there...

Sorry, make those .htaccess rules

RewriteCond %{REQUEST_URI} symphony/assets/
RewriteRule ^(symphony/assets/.*) cms/$1 [L]

RewriteCond %{REQUEST_URI} ^/extensions/
RewriteRule ^(extensions/.*) cms/$1 [L]

JIT will not install with this setup, so make sure it is enabled before doing all this.

It may be easier to install at the root ;o)

It seems this solution is not compatible with language redirect, even if I remove the rules from the .htaccess.

I got error 401 (Too many redirects occurred trying to open ...). I was been redirected to domain.net/en/en/en/en/...

The redirect rules are the ones that I showed before, but there is also the language redirect event, where the PHP function header is called to redirect to other page.

For anyone who is still looking at this - for feedback.

I know it might be ugly but I've managed to tackle it somehow.

leave your Symphony subfolded intact and just edit the index.php

$oldDomain = rtrim(rtrim($_SERVER['HTTP_HOST'], '\/') . dirname($_SERVER['PHP_SELF']), '\/');
$newDomain = preg_replace("~/.*~","",$oldDomain);
define('DOMAIN', $newDomain);

Then add a .htaccess in your root directory redirecting all request to your subdirectory.

# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1

@gunglien, thank god! I've been waiting for this solution, it work exactly what it say.

@gunglien works for me too, but I had to add a slash in the redirect in content.login.php on line 156 to redirect(SYMPHONY_URL . '/'); to smooth out the login. But that might have been a bit wonky due to a bunch of legacy redirects on my system anyway.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details