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

  • SEARCH
  • Home
  • 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 8472781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:10:17+00:00 2026-06-10T17:10:17+00:00

I have the following link in my view which calls a post by passing

  • 0

I have the following link in my view which calls a post by passing the date and the slug of the post:

<?php echo $this->Html->link($post['Post']['title'],
array('controller' => 'posts', 'action' => 'view', 'date'=>date('Y/m', strtotime($post['Post']['datetime'])), 'slug'=> $post['Post']['slug'])); ?></h2>
<h4><?php echo $post['Post']['datetime']; ?><

As you can see I use strtotime to make the datetime prettier for use in the URL.

I don’t actually use the date in the controller for pulling the post out of the database, just the slug so it doesn’t matter too much.

The problem however is that because the date has a / in it, the router gets confused and thinks it’s two seperate parts of the url. How do I fix this?

My route is as follows:

Router::connect('/news/:date/:slug',
                array('controller' => 'posts', 'action' => 'view'),
                array(
                    //'date'   => '[A-Za-z0-9\._]+',
                    'slug' => '[A-Za-z0-9\._]+',
                    'pass' => array('date', 'slug')
                ));
  • 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-06-10T17:10:18+00:00Added an answer on June 10, 2026 at 5:10 pm

    Are you using cake 2?? if you do, you can try this, as book says:

    In addition to the greedy star /* there is also the /** trailing star
    syntax. Using a trailing double star, will capture the remainder of a
    URL as a single passed argument. This is useful when you want to use
    an argument that included a / in it:

    <?php
    Router::connect(
        '/pages/**',
        array('controller' => 'pages', 'action' => 'show') );
    ?>
    

    The incoming URL of /pages/the-example-/-and-proof would result in a
    single passed argument of the-example-/-and-proof.

    But I guess you should pass slug first.

    Otherwise you can change your / by - (or anything else). But, if you want to keep them, you can declare the date as separated parameters in your route, something like:

    Router::connect(
        '/news/:year/:month/:day',
        array('controller' => 'posts', 'action' => 'view', 'day' => null),
        array(
            'year' => '[12][0-9]{3}',
            'month' => '0[1-9]|1[012]',
            'day' => '0[1-9]|[12][0-9]|3[01]'
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I have the following case: Edited: removed link In IE7 gives me different view
I have the following link on index page <td align=center><a href=../athena/admin/update.php?id=' . $data [keyword]
I have the following output (via link) which displays the var_dump of some XML
I have following XsL which opens the link in the same window. I would
I have a link to a potentially large table of data: <a class=tabledata href=table.php>View
Isit possible to have a zend view which returns nothing? I have the following,
I have a view with the following link generator: - @tags.each do |tag| =
I have a Rails 3.1 application where the view has the following link: <%=
I'm using Fancybox 1.3.4 with ASP.NET MVC 3. I have following link : <a

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.