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

The Archive Base Latest Questions

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

If we have many rules which cannot be normalized, there would be a long

  • 0

If we have many rules which cannot be normalized, there would be a long list of rules in .htaccess, which would probably behave as a long if-else condition.

Is there any way, we can apply rewritting rules effeciently for long list of rules?

  • 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-10T19:15:19+00:00Added an answer on June 10, 2026 at 7:15 pm

    Yes, not using .htaccess at all. Just re-route everything (except images, js, css, etc.) to index.php and handle routing business in PHP, not in .htaccess.

    Using .htaccess is a pain. Just forward everything to index.php and go from there. If the url is http://www.google.com/test/bla/bla/, it gets rerouted to http://www.google.com/index.php/test/bla/bla/. In index.php you can then explode the string ‘test/bla/bla/’ to get your arguments in an array.

    You can do whatever you want from there.

    EDIT:
    There’s no real overhead in this solution. You just create infinite flexibility. You’ll just need a few things:

    A) A url parser. You can make this as complicated as you want. You can have it explode the url and that’s it. You can extend it with complex functionality like Reflection, etc. A minimalist url parser contains maybe 5 lines of code. (Get the url, explode, return the array.)

    B) Some sort of router/routing mechanism. Determine ‘where’ you should send the request based on the url. The url parser gave you a list of arguments – what is the structure of that array?

    Is the first argument always some sort of controller? Then try finding that controller. Is the second argument always an action? Search for the corresponding action within that controller.

    Or… does the first argument always resolve to a specific page? Then include that specific page.

    It all depends on your requirements and your application, but one thing is for sure: it’s always easier to work with than with .htaccess. You can implement this basically in any stage of your application development, as the url’s stay the same, but only the handling differs.

    EDIT2
    Oh, and something else – if you implement this solution and you end up with either a switch statement with 100 cases or an endless if/else condition block: you’re doing it wrong. You should always be able to have some sort of automated routing.

    If your application works with procedural code and you use includes: put all the ‘includeable’ pages in a folder and just try to resolve the page by including it. If it’s non-existant, throw an error. No need to put every single page in a switch statement.
    On the specific pages themselves; check whether the user has enough rights to view that page. Don’t do that whilst routing, the router shouldn’t be aware of security context.

    If you have an object oriented structure with controllers, make sure you can identify ‘action methods’. Use docblocks, prefixes (doSomething()) or whatever to make sure the router can only access methods that are supposed to be accessed from the outside. As for security: don’t validate whether the user is allowed to call that action in the router. In an object oriented application there are 100 styles of access control management, but the router is just for routing. Add a security layer of some sort, don’t let the router decide whether the user can come in. You can reroute the request if some security mechanism finds out the user doesn’t have enough credentials. Reroute to some ‘illegal request’ page.

    This answer got a bit too long and elaborates more on other topics than just on what you asked for, for which I’m sorry. 🙂

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

Sidebar

Related Questions

Hii, I have a parser which has many rules and no problem with it
I have a business model called Customer which has many required properties (via DataAnnotations)
I have a form with many fields which are displayed progressively. I need to
i have defined a grammar with many rules, that uses many keywords. imagine it
I have many graphic resources in my application and I would like to support
Basicall I have three Tables Users Roles and USerRoles with Many to many Relationship.
Right now I have 3 tables: User, Roles, and User_Roles for the many-to-many association.
I have many different NSArray 's stored in .dat files, in the Documents folder
I have many PowerPoint presentations that I need to be able to add to
I have many many files in a folder, and I want to process them

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.