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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:10:13+00:00 2026-05-20T05:10:13+00:00

I’m using the Zend Framework to create an API I want to use apache

  • 0

I’m using the Zend Framework to create an API

I want to use apache mod_rewrite to change some of the URI’s a bit,
but I’m still in the n00b level of apache rewite’s

currently I’m using the default ZF .htaccess file to remove the index.php file and pretty the URI’s:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

currently the URI’s looks like this:

http://domain.com/module/index/action/id/5/format/json

What I would like to do:

  • If the controller (after /module) equals “index” it should be removed from the URI.
  • If there is an int after action/ the “id” param should be removed and only pass the value.
  • And finally I would like the to append the format as a suffix to the end of URI e.g. …/action/5.json

So that when I get the following URI:

http://domain.com/module/action/5.json

it will still points to:

http://domain.com/module/index/action/id/5/format/json

Is it possible to do all of this in one statement?
or would it be a better option to add a custom route in the ZF Bootstrap?

  • 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-20T05:10:14+00:00Added an answer on May 20, 2026 at 5:10 am

    Typically in a Zend Framework application, the only url rewriting that occurs using Apache’s mod_rewrite at the .htaccess level is the rewriting you have in the question. This pushes all requests through the framework which then has it’s own internal mechanism for handling the request.

    This internal process of mapping a url to a (module, controller, action) triple and setting request parameters is called “routing”. Zend Framework allows you to define custom routes.

    Typically, routes are defined at the bootstrapping stage; after all, it has to be done early in the process so the system can determine which controller needs to be instantiated to handle the request.

    The ZF documentation for routing describes it pretty well.

    In summary: Best to do this via custom route defined within the application.

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

Sidebar

Related Questions

No related questions found

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.