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 8243865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:39:42+00:00 2026-06-07T21:39:42+00:00

I’m using CakePHP 2.2.0 and I need to create one route that get this

  • 0

I’m using CakePHP 2.2.0 and I need to create one route that get this kind of page:

http://www.example.com/users/mypage.php

Following the cakephp documentation, I have found this page: http://book.cakephp.org/2.0/en/development/routing.html#file-extensions

where I read that I must to use:

Router::parseExtensions('php');

I have added this line in my routes.php file (above the routes), and than I added this route:

Router::connect('/users/mypage.php', array('controller' => 'users', 'action' => 'mypage'));

So, inside UsersController I added this action.

Unfortunately, Only the requests sent to www.example.com/users/mypage work good(the mypage action is called), If I try www.example.com/users/mypage.php I get a 404 not found error.

I really do not understand the reason, As the documentation says:

This will tell the router to remove any matching file extensions, and
then parse what remains.

So, that’s exactly what I need, I have to interpret (only for this action) that the mypage action is called when the user digits /users/mypage.php (with extension).

I did not added anything else. AppController is as default, and my UsersController only has the mypage() method.

I do not know if NGINX is the problem, I write the configuration of the domain below:

server {
        listen 80;
        server_name www.example.com;
        root /home/users/example.com/www/app/webroot/;

        access_log /home/users/example.com/log/access.log;
        error_log /home/users/example.com/log/error.log;

        location / {
                index index.php index.html;
                try_files $uri $uri/ /index.php?$uri&$args;
        }

        location ~* \.php$ {
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
                include         /etc/nginx/fastcgi_params;
                fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        }
}

I think the question is clear, How to route the request to a specific Controller’s action if the request has the extension ?

I need:

www.example.com/users/mypage.php ==> to UsersController mypage()
  • 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-07T21:39:44+00:00Added an answer on June 7, 2026 at 9:39 pm

    First, you either use parseExtensions() or add “.php” to the url template with connect(). You cannot use both at the same time. Whatever you choose, I suggest an experiment. Try using any other extensions such as “php5” and see that it works just fine. So obviously your problem is your nginx configuration:

    location ~* \.php$ {
        ...
    }
    

    Those lines are telling nginx to parse anything in the url that ends in .php as a hard file in your file system. This is not very easy to overcome. You can use try_files in that directive having a fallback to another script, which is tricky, or you could simply just use another extension for your url 🙂

    I hope this gives you a good hint of what you have to do.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.