Change path url or removing it

Welcome me!

Hi Sir/Madam,

I want to replace or remove domain.com/index.php/joke/category/girl to my local language or remove joke using .htaccess.

Thank you.

<?php

require realpath(dirname(__FILE__) . '/../../config.php');

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => MAD_APP_NAME,
    // preloading 'log' component
    'preload' => array('log'),
    // autoloading model and component classes
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.extensions.*',
        'application.extensions.yii-mail.*',
    ),
    'modules' => array(
        'admin',
        // uncomment the following to enable the Gii tool
    /*
        'gii' => array(
            'class' => 'system.gii.GiiModule',
            'password' => 'ninja',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters' => array('127.0.0.1', '::1'),
        ),
     */
    ),
    // application components
    'components' => array(
        'CURL' => array(
            'class' => 'application.extensions.curl.Curl',
            //you can setup timeout,http_login,proxy,proxylogin,cookie, and setOPTIONS
            //eg.
            'options' => array(
                'timeout' => 0,
            ),
        ),
        'mail' => array(
            'class' => 'ext.yii-mail.YiiMail',
            'transportType' => 'php',
            // folder in themes views
            'viewPath' => 'email-templates',
            'logging' => true,
            'dryRun' => false
        ),
        'user' => array(
            // enable cookie-based authentication
            'allowAutoLogin' => true,
            'loginRequiredAjaxResponse' => true,
            'loginUrl' => array('/user/login'),
        ),
        // uncomment the following to enable URLs in path-format
        'urlManager' => array(
            'urlFormat' => 'path',
//            'showScriptName'=>false,
            'rules' => array(
                'site/page/<slug:[\\w_-]+>' => 'site/page_cms/slug/<slug>',
                '[B][U]joke[/U][/B]/<id:\\d+>' => 'joke/view/id/<id>',
                '[B][U]joke[/U][/B]/category/<category:[\\w_-]+>' => '[B][U]joke[/U][/B]/category/category/<category>',
                '[B][U]joke[/U][/B]/category/<category:[\\w_-]+>/<page:\\d+>' => '[B][U]joke[/U][/B]/category/category/<category>/<page>',
                'admin' => 'admin/account/index',
                'admin/login' => 'admin/account/login',
                'admin/logout' => 'admin/account/logout',
                '<controller:\\w+>/<id:\\d+>' => '<controller>/view',
                '<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>',
                '<controller:\\w+>/<action:\\w+>' => '<controller>/<action>',
            ),
        ),
        /*
          'db' => array(
          'connectionString' => 'sqlite:' . dirname(__FILE__) . '/../data/testdrive.db',
          ),
         */
        'db' => array(
            'connectionString' => 'mysql:host=' . MAD_DB_HOST . ';dbname=' . MAD_DB_NAME,
            'emulatePrepare' => true,
            'username' => MAD_DB_USER,
            'password' => MAD_DB_PWD,
            'charset' => 'utf8',
//            'enableParamLogging'=>true,
//            'enableProfiling'=>true,
        ),
        'errorHandler' => array(
            // use 'site/error' action to display errors
            'errorAction' => 'site/error',
        ),
        'log' => array(
            'class' => 'CLogRouter',
            'routes' => array(
                array(
                    'class' => 'CFileLogRoute',
                    'levels' => 'error, warning',
                ),
            // uncomment the following to show log messages on web pages
            /*
              array(
              'class'=>'CWebLogRoute',
              ),
             */
            ),
        ),
    ),
    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params' => array(
        // this is used in contact page
        'adminEmail' => MAD_ADMIN_EMAIL,
        'madServiceUrl' => 'http://www.madlogics.com/service.php',
    ),
    'theme' => MAD_THEME,
);

mojo,

What you’re asking for is a means to upset the functionality of your index.php (which is looking for that “path” following a slash in the URI). IF you do this, you’ll need to alter index.php, too.

# in .htaccess in domain.com's DocumentRoot

RewriteRule ^index\\.php/joke/([a-z/]*)$ incex.php/$1 [L]

This will look for “joke” at the start of the “path” which follows index.php in the {REQUEST_URI} string and simply removes “joke/”.

This was so trivial that I must refer you to the mod_rewrite tutorial Article linked in my signature. It’s been linked here for nearly 10 years and has helped MANY members in the past.

Regards,

DK