Search code examples
codeigniterurl-routingexpressionengine

ExpressionEngine 2, admin path routing


My first day with ExpressionEngine, I know basic CodeIgniter.

  1. ./admin.php renamed to ./john_doe.php
  2. updated the $config['cp_url'] value to http://mysite.com/john_doe.php

I want to redirect mysite.com/johndoe to mysite.com/john_doe.php, just for an alternative to administrate EE2.

In CodeIgniter (according to user guide) this line must be added into ./application/config/routes.php file:

$route['johndoe'] = "john_doe.php";

The question is: How can I do this in ExpressionEngine?

Thanks in advance.


Solution

  • If all you want to do is redirect /johndoe to /john_doe.php, you don't need to do anything with ExpressionEngine (unless you really want to).

    Instead, just create a simple mod_rewrite rule in Apache's .htaccess file:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^johndoe /john_doe.php [R=301,L]
    </IfModule>
    

    It used to be difficult to mask access to the Control Panel in EE1, but as of EE 2.2 it's simple — simply rename the included file admin.php to whatever you'd like.

    Then use that filename in your URL to access the Control Panel instead of the [renamed] system folder:

    http://example.com/Xtr3m-H4x0r.php
    

    ExpressionEngine will rewrite all of its Control Panel links to use the masked access filename -- just don't forget to edit the file to make sure the path to your system folder is set correctly:

    $system_path = './renamed-system-folder';