1

I have completed CMS. This CMS have many controllers: news, content, articles, etc. Also have modules like "modules/shop/controllers/cart.php", "modules/shop/controllers/items.php".

ATM URLs are:

  • /shop/some-category/
  • /shop/nokia/n73.html
  • /content/about-company.html
  • /articles/phones/full/1.html

Now I need urls like: - /nokia.html - /my/super/article-about-phones.html

So, I need custom URLs for any controlles (shop, news, content, etc). As I know, I can't execute controller from controller.

How I can solve a problem? I have no idea how to rewrite Router core class. Any ideas? For me I have 1 way - rewrite architecture of full product but I have no time :( Thnx alot.

P.S. ATR routes.php is:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$lang_prefix = '(([a-z]{2}/)?)';

$route[$lang_prefix.'ajax/shop/(.*)'] = "shop/ajax/$3";

$route['cron/(.*)'] = "cron/$1";

$route[$lang_prefix.'content/(.*)'] = "content/index";
$route[$lang_prefix.'faq/ask/(.*)'] = "faq/ask";
$route[$lang_prefix.'faq/(.*)'] = "faq/index";

$route[$lang_prefix.'sitemap'] = "sitemap/index";
$route[$lang_prefix.'contact'] = "contacts/index";

$route[$lang_prefix.'news/(.*?)/full/[0-9]+'] = "news/full";
$route[$lang_prefix.'news/(.*)'] = "news/index";



$route[$lang_prefix.'compare/[0-9]+[0-9\/]+'] = "shop/compare";
$route[$lang_prefix.'cart/(.*?)'] = "shop/cart/$3";
$route[$lang_prefix.'cart'] = "shop/cart";

$route[$lang_prefix.'order'] = "shop/order";
$route[$lang_prefix.'order/check'] = "shop/order";
$route[$lang_prefix.'order/successful/[A-z_\-0-9]+'] = "shop/order/successful";

$route[$lang_prefix.'search/(name|price|rating)/(asc|desc)(.*)'] = "shop/search";

$route[$lang_prefix.'shop/(.*)/(name|price|rating)/(asc|desc)(.*?)'] = "shop/items/index";
$route[$lang_prefix.'shop/(.*?)/(.*?)/add-comment'] = "shop/items/add_comment";
$route[$lang_prefix.'shop/(.*?)/(.*?)'] = "shop/items/details";
$route[$lang_prefix.'shop/(.*)'] = "shop/items/index";



$route[$lang_prefix.'feedback'] = "feedback/index";
$route[$lang_prefix.'callback'] = "feedback/index";

$route[$lang_prefix.'article/(.*?)/full/(.*)'] = "articles/full";
$route[$lang_prefix.'article/(.*)'] = "articles/index";

$route[$lang_prefix.'gallery/(.*?)/full/(.*)'] = "gallery/full";
$route[$lang_prefix.'gallery/(.*)'] = "gallery/index";


$route[$lang_prefix.'admin/ajax/(.*)'] = "admin/ajax/$3";
$route[$lang_prefix.'admin'] = "admin/main/index";


$route[$lang_prefix.'admin/login'] = "admin/auth/login";
$route[$lang_prefix.'admin/logout'] = "admin/auth/logout";

$route[$lang_prefix.'admin/(.*)'] = "admin/$3";

$route['default_controller'] = "shop/showcase";
1
  • you need your url to contain the file extension .html ?
    – afarazit
    Jun 14, 2011 at 23:15

1 Answer 1

0

You could use a mod_rewrite to direct all requests to a .html file to go to a special static content controller. So:

my/super/article-about-phones.html

would redirect to:

/content/static/article-about-phones/

This might look something like this:

Options +FollowSymLinks 
RewriteBase / 
RewriteEngine On

RewriteRule  ^(.+)/([^/]+)\.html$ /content/static/$1/ [NC,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.