PyroCMS

Notice: PyroCMS v 2.2.x is depreciated and is no long under development. This documentation is provided as-is, free of charge, for reference in existing websites.

Page URLs

By default, most URLs are routed to the PyroCMS Pages module, which is where your site's page tree is stored. If you go to Content → Pages, you'll see something like this:

Page Tree

If you are familiar with a page tree, you should be right at home! This represents pages in a nested hierarchy, so if you have a page at yoursite.com/about, a nested page with the slug of history will be accessed at yoursite.com/about/history. Pretty simple!

By default, URLs are strict meaning that if you create a page with the URL yoursite.com/team and you tried to access yoursite.com/team/bob, the Pages module would only look for a page with the URI of team and return a 404. However, in the Options tab of your pages, you can turn strict URLs, so that yoursite.com/team/bob will display the page you created at yoursite.com/team (so will yoursite.com/team/foo and anything else, for that matter). See the Pages module documentation for more information.

The Home Page

Although PyroCMS comes with a default home page, any page in PyroCMS can be the home page. Just go into the Options tag in the page and select the check box that says "Is default (home) page?". This will tell PyroCMS to load this page whenever your site's root URL is loaded.

Home Page

404 Page

All pages that are not found in PyroCMS are routed to the Pages module, where a special 404 page handles them. This page simply has to have a slug of 404, and PyroCMS will use it as the 404 and set the correct 404 headers accordingly.

Module URLs

PyroCMS is a modular CMS, and modules in PyroCMS can have their own front-end URLs in additon to back-end URLs.

The first segment in a URL will be the module name, so to access the "news" module you would call /news. This would then load the news.php controller in your news module (because the names match) and reference the index() method. Calling /news/category would call the method foo() inside the news.php controller.

The second segment could be a method inside the default controller as outlined above, or it could be a secondary controller. For example, /news/gallery/view/some-article would load the gallery.php controller inside the news module, and reference the view() method.

Most modules do not use front-end URLs, but some do. Check with the documentation of your modules to see if they have any front-end URLs.

Forcing Clean URLs

During installation, PyroCMS will ask you if you have Apache's mod_rewrite installed. This has to do with the PHP framework PyroCMS is built on, CodeIgniter.

In CodeIgniter, everything is routed through the index.php file, so your URL might look like:

 http://www.example.com/index.php/about

Obviously, we want to remove that ugly index.php, and you can do so with an .htaccess file, and Apache's mod_rewrite.

To remove the index.php, create a file at the root of your PyroCMS site called .htaccess. You can find out more about .htaccess here, but for our purposes here we just want to use it to hide index.php in our URLs.

Not every web server is the same, but something along these lines should work for your purposes:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

This tells Apache to remove the index.php from the URL entirely (whilst still serving any 'real' files -f or directories -d from your docroot.)

Your URLs will now look clean and smooth:

 http://www.example.com/about

If you chose the no mod_rewrite during installation and your links keep adding the index.php, open up system/cms/config/config.php and change:

 $config['index_page'] = 'index.php';

to:

 $config['index_page'] = '';

This will stop PyroCMS from prefixing links with index.php when URLs are automatically generated by the system.