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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:04:51+00:00 2026-05-27T03:04:51+00:00

Clean URLs also known as RESTful URLs are user-friendly, purely structural, and do not

  • 0

“Clean URLs” also known as “RESTful URLs” are user-friendly, purely structural, and do not contain a query string. Instead they contain only the path of the resource.

ie: “http://twitter.com/users/show/”+username+”.json”

Questions about server-side functionality:

  1. Do I need to make a unique server-side API script for each directory?

  2. Can I forward all requests to just one script if so how do I
    pull useful information from the Clean URL structure ($_GET[‘url_structure’])?

  3. Why does twitter call to a .json file
    that surely doesn’t exist. It must get generated on request. How
    does this work? This leads me to believe that the answer to question
    2 is yes.

  • 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-27T03:04:52+00:00Added an answer on May 27, 2026 at 3:04 am

    1) Not if you use a RESTful framework like RecessPHP or if you use a mod_rewrite rule in your .htaccess file to redirect all API requests to a single PHP file (known as the front controller).

    .htaccess

    RewriteEngine On
    RewriteRule ^/api/ api.php
    

    api.php

    $request = $_SERVER['REQUEST_URI'];  //this would be /users/show/abc.json
    

    2) You can use the rewrite module of apache to redirect all api requests to a special PHP file that handles them. Depending on your apache configuration, the original requested (RESTful) url will be stored in a server variable in PHP, I believe it’s $_SERVER['REQUEST_URI']. Of course you could also just pass along a $_GET[] variable to PHP that contained the RESTful url.

    .htaccess

    RewriteEngine On
    RewriteRule ^/api/([^\.]+).(xml|json|atom) api.php?url=$1&type=$2
    

    api.php

    $request_parts = explode('/', $_GET['url']); // array('users', 'show', 'abc')
    $file_type     = $_GET['type'];
    
    $output = get_data_from_db(); //Do your processing here
                                  //You can outsource to other files via an include/require
    
    //Output based on request
    switch($file_type) {
        case 'json':
            echo json_encode($output);
            break;
        case 'xml':
            echo xml_encode($output); //This isn't a real function, but you can make one
            break;
        default:
            echo $output;
    }
    

    3) Twitter (and many other APIs) use this because it is a convenient way of supplying the format that an application expects back from an API. All of the API requests are rerouted to a single PHP file which handles creating all the files and echoing their contents to the output. The file is never actually stored on the server (unless it is cached).


    Good Resources

    • mod_rewrite, a beginner’s guide
    • Create a REST API with PHP
    • Recess PHP Framework | Tutorials

    A note on RecessPHP. It’s certainly a great tool and I would encourage you look at it (maybe at its source to get an idea of how it processes things), but that said, it seems a bit clunky to me. The fact that path names are written in special comments seems very not-PHP to me. I’d stray away from this, and I wouldn’t call it the perfect framework, but it’s certainly a start. Good luck!

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

Sidebar

Related Questions

After asking this question: Clean URLs for search query? I tried something with mod_rewrite:
I'm trying to create clean URLs on my website. Now I succeeded in configuring
I'm trying to use sed to clean up lines of URLs to extract just
I've used routing in Codeigniter to get nice clean URLs to my pages. I
I have a PHP-Apache application using mod_rewrite for clean URLs. I am having a
I am a big proponent of using super clean urls for all pages and
I have an app that uses several prefixes and, while not frequent, it's also
I want to allow clean URLs in the form of domain.com/me@msn.com which should redirect
I have website developed in classic ASP . The URL is not SEO friendly
I am using mod_rewrite to make my URLs clean. By doing so: RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$

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.