Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7024711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:52:40+00:00 2026-05-27T23:52:40+00:00

Recently I’ve been doing some research into SEO and how URIs that use hyphens

  • 0

Recently I’ve been doing some research into SEO and how URIs that use hyphens or underscores are treated differently, particularly by Google who view hyphens as separators.

Anyway, eager to adapt my current project to meet this criteria I found that because Kohana uses function names to define pages I was receiving the unexpected ‘-‘ warning.

I was wondering whether there was any way to enable the use of URIs in Kohana like:

http://www.mysite.com/controller/function-name

Obviously I could setup a routeHandler for this… but if I was to have user generated content, i.e. news. I’d then have to get all articles from the database, produce the URI, and then do the routing for each one.

Are there any alternative solutions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:52:40+00:00Added an answer on May 27, 2026 at 11:52 pm

    Note: This is the same approach as in Laurent’s answer, just slightly more OOP-wise. Kohana allows one to very easily overload any system class, so we can use it to save us some typing and also to allow for cleaner updates in the future.

    We can plug-in into the request flow in Kohana and fix the dashes in the action part of the URL. To do it we will override Request_Client_Internal system class and it’s execute_request() method. There we’ll check if request->action has dashes, and if so we’ll switch them to underscores to allow php to call our method properly.

    Step 1. Open your application/bootstrap.php and add this line:

    define('URL_WITH_DASHES_ONLY', TRUE);
    

    You use this constant to quickly disable this feature on some requests, if you need underscores in the url.

    Step 2. Create a new php file in: application/classes/request/client/internal.php and paste this code:

    <?php defined('SYSPATH') or die('No direct script access.');
    
    class Request_Client_Internal extends Kohana_Request_Client_Internal {
    
        /**
         * We override this method to allow for dashes in the action part of the url
         * (See Kohana_Request_Client_Internal::execute_request() for the details)
         *
         * @param   Request $request
         * @return  Response
         */
        public function execute_request(Request $request)
        {
            // Check the setting for dashes (the one set in bootstrap.php)
            if (defined('URL_WITH_DASHES_ONLY') and URL_WITH_DASHES_ONLY == TRUE) 
            {
                // Block URLs with underscore in the action to avoid duplicated content
                if (strpos($request->action(), '_') !== false)
                {
                    throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(':uri' => $request->uri()));
                }
    
                // Modify action part of the request: transform all dashes to underscores
                $request->action( strtr($request->action(), '-', '_') );
            }
            // We are done, let the parent method do the heavy lifting
            return parent::execute_request($request);
        }
    
    } // end_class Request_Client_Internal
    

    What this does is simply replacing all the dashes in the $request->action with underscores, thus if url was /something/foo-bar, Kohana will now happily route it to our action_foo_bar() method.

    In the same time we block all the actions with underscores, to avoid the duplicated content problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I'm doing some work on RTMP streaming, that is using Flowplayer to integrate
Recently I have been told that static class/methods are evil. Take for example my
Recently I wrote myself an Ear Clipping Triangulator as personal research. After visualizing some
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I started changing some of our applications to support MS SQL Server as
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently our site has been deluged with the resurgence of the Asprox botnet SQL
Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's
Recently I've noticed that on occasion I do not get a mayorship notification when
Recently I have been dealing with windows LogonUser API. The LogonUser api returns different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.