5

I use PHP. I want to setup a micro site as a prototype, where I can work with the frontend only, separated from any CMS.

URL Rewrite

I also want the URL rewrite to be correct, like http://www.test.com/products/tables/green/little-wood123/

Question(s)

  1. Is there any free class for URL rewriting? I searched but found none.
  2. If that is not the way to go, what framework is nice for this? It should be tiny, easy to use and support URL rewrite.
1
  • I don't understand what you're describing here. If you need something to deal with rewrites, you presumably have enough documents that something is…managing them. What, in your situation, is that thing? (As a sidenote, you've tagged a question that's supposedly about not using a CMS with the CMS tag. Maybe you're giving yourself a hint.) Pretty much any application framework is going to have a module to handle your URL paths. Barring much more specific requirements, you can probably just pick one.
    – Su'
    Commented Oct 2, 2012 at 10:26

1 Answer 1

5

There are several PHP microframeworks that allow you to create a simple application with "pretty URLs" by defining the available routes:

For example, this short Limonade app would respond to requests at the root domain (example.com/) and at the specified route (example.com/hello):

<?php
require_once 'vendors/limonade.php';
dispatch('/', 'home');
  function home()
  {
      return 'You are home.';
  }
dispatch('/hello', 'hello');
  function hello()
  {
      return 'Hello world!';
  }
run();

All of these frameworks use Apache rewrite rules in .htaccess to direct all requests to your index.php file, which is typically where you define the routes and methods. This is called the "front controller pattern". You could write your own front controller if you don't want to use the frameworks listed above, but there's probably no need to reinvent the wheel if it's a simple application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.