Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore an optional segment #38

Open
robsonsobral opened this issue Sep 14, 2016 · 0 comments
Open

Ignore an optional segment #38

robsonsobral opened this issue Sep 14, 2016 · 0 comments

Comments

@robsonsobral
Copy link

robsonsobral commented Sep 14, 2016

Hi!

I need to make a website available using two different URLs patterns: domain.com and domain.com/city_code.

My approach currently is to use an index.php and a ny/index.php. I've split my configurations and variables on both index.php files and the config.php. But I still need to update the NGINX configuration file, coding a new location directive for every new city.

Before I lose control of everything, please, is it possible to achieve this using Resource Router?

I tried using the following code, but it doesn't look enough:

$config['resource_router'] = array(
    '(sp)/:any/:any' => function($router, $wildcard_1, $wildcard_2) {
        $router->setTemplate( $wildcard_1.'/'.$wildcard_2 );
        $assign_to_config['global_vars']['cv-city_segment']         = "sp";
        $assign_to_config['site_url'] = '/'.$assign_to_config['global_vars']['cv-city_segment'];
        $assign_to_config['global_vars']['cv-city_ch_blog_id']      = "";
        $assign_to_config['global_vars']['cv-city_ch_events_id']    = "";
        $assign_to_config['global_vars']['cv-city_cat_blog_id']     = "";

        // a different variable, so we can change the city segment easier, if needed
        $assign_to_config['global_vars']['cv-city_code']            = 'sp';
    }
);

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant