Skip to content

Latest commit

 

History

History
108 lines (76 loc) · 3.3 KB

cmsms-config.md

File metadata and controls

108 lines (76 loc) · 3.3 KB

JSDD > CMSMS + url rewriting

Configure a CMSMS website with url rewriting support

Ok, my requirements are a bit special on this case:

Current configuration:

Setting up the proxy redirection and seo urls

In my vhost root, .htaccess goes:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine on

  # old urls
  RewriteRule ^index.html$   /                 [L,R=301]
  RewriteRule ^content.html$ /new-content.html [L,R=301]
  # ...

  # proxy
  RewriteRule ^(.*)$ http://dev.my-agency.com/my-client-domain/$1 [P,L,QSA]
</IfModule>

Seting up the visible url in browser's address bar

A little dig in the CMSMS documentation gave me the hints:

In the CMSMS directory/config.php, add:

// allow website to stay behind an url rewriting module
$config['root_url'] = 'http://www.my-client-domain.com';

// allow url rewriting to keep the current seo
$config['url_rewriting']  = 'mod_rewrite'; // with apache
$config['page_extension'] = '.html';
$config['query_var']      = 'page';

In the CMSMS directory/.htaccess, uncomment this line:

#Options +FollowSymLinks

becomes:

Options +FollowSymLinks

Set the RewriteBase to the subdirectory on the dev subdomain :

RewriteBase /

becomes:

RewriteBase /my-client-domain

Find the following lines, uncomment them if needed and add your page extension (.html in here) in the RewriteRule regex:

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.+)$ index.php?page=$1 [QSA]

becomes:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.html$ index.php?page=$1 [QSA]

Access the admin

Well everything front is working fine but in my case, I can't access the admin anymore. No wrong login/password warning but I stay on the login page...

My dirty fix for the moment: set back the admin url to the dev address. After all, it's all for the client to see, then he can keep on remembering who made his website. Add the following line in CMSMS config.php, don't forget to append the admin directory's name (admin here):

$config['admin_url'] = 'http://dev.my-agency.com/my-client-domain/admin';

CMSMS-side

Finally, don't forget to give your pages the right alias/url. Get to the admin, in the Content>Pages list, setup the page alias and url fields to the right name. They both will be matched to route to your content, you can event use content.html in url with no harm:

Working:

page alias: content

url: content

url: content.html

And this is it.