This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

Let's assume the site is accessed as http://www.example.com and Concrete5 is in the c5 subdirectory which you want to hide in the url.

(1). set the rewrite rules for the root directory

/.htaccess - in the site root directory

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Add trailing slash if path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.example.com/$1/ [R=301,L]

# Change http://example.com to http://www.example.com (Optional)
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^/?(.*)$ http://www.example.com/$1 [R=301,L]

# Rewrites http://www.example.com/ to http://www.example.com/c5 except for directories we want normal access to
RewriteCond %{REQUEST_URI} !^/c5
# exclude other sub-directories if necessary
RewriteCond %{REQUEST_URI} !^/testphp
RewriteCond %{REQUEST_URI} !^/plesk-stat
RewriteRule ^(.*)$ c5/$1 [L]
</IfModule>

(2). set the rewrite rules for prettyurls in the c5 subdirectory

/c5/.htaccess (if pretty urls are enabled)

# -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
# -- concrete5 urls end --

(3). Edit config/site.php and define another DIR_REL2. DIR-REL will be the url subdirectory (empty) and DIR_REL2 will be the server subdirectory (c5)

define('DIR_REL', '');
define('DIR_REL2', '/c5');
define('ENABLE_CMS_FOR_PATH', '');

(4). Edit concrete/libraries/request.php and change DIR_REL to DIR_REL2 in the parsePathFromRequest functon.

Note. remember to re-apply this change to request.php every time you upgrade concrete5. Do this before you run /tools/required/upgrade.php or you will get 404 errors.

private static function parsePathFromRequest($var) {
       $path = (isset($_SERVER[$var])) ? $_SERVER[$var] : @getenv($var);
       if (!$path) {
          return false;
       }

       // if the path starts off with dir_rel, we remove it:

       if (DIR_REL2 != '') {
          $dr = trim(DIR_REL2, '/');
          $path = trim($path, '/');
          if (strpos($path, $dr) === 0) {
             $path = substr($path, strlen($dr));    
          }
       }

       $path = trim($path, '/');
       if (strpos($path, DISPATCHER_FILENAME) === 0) {
          $path = substr($path, strlen(DISPATCHER_FILENAME));    
       }
...
Loading Conversation