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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:16:35+00:00 2026-05-14T14:16:35+00:00

I am developing a website using PHP and Apache. I wanna turn my URLs

  • 0

I am developing a website using PHP and Apache.
I wanna turn my URLs from

http://www.example.com/book.php?book=title

into something like this, if it is possible of course:

http://www.example.com/book/title

Notice that the title of the books are unique and cannot be repeated.

I`ve read about this, but none of the posts were clear enough for a beginner like me.
Do you guys know any tutorial that explains that?

Thanks.

  • 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-14T14:16:35+00:00Added an answer on May 14, 2026 at 2:16 pm

    Expanding on @Rodolphe’s and @Galen’s replies a little bit.

    If your needs for url rewriting are limited, a hardcoded .htaccess with rules described in Rodolphe’s example will do nicely.

    However, as Galen suggests, your needs may be unknown, or you may want to expand on them later, without the need to touch your rewriting rules, once you have them working.

    A common way to do it, is to design your application around a URL scheme which is www.host.com/controller/action/parameter. An example of such a URL could be www.host.com/book/view/1, which could then internally be handled in a number of ways.

    1)

    You have separate scripts for every controller. You then rewrite every request to the form $controller.php?action=$action&param=$param, redirecting non-matching or non-valid requests to a default controller.

    # Serve files and directories as per usual,
    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    
    # If the request uri doesn't end in .php
    # and isn't empty, rewrite the url
    RewriteCond %{REQUEST_URI} !.php$
    RewriteCond %{REQUEST_URI} !^$
    # Try matching against a param request first
    RewriteRule (.*?)/(.*?)/(.*?) $1.php?action=$2&param=$3 [L]
    # If it didn't match, try to match an action
    RewriteRule (.*?)/(.*?) $1.php?action=$2 [L]
    
    # redirect all other requests to index.php,
    # your default controller
    RewriteRule .* index.php [L]
    

    2)

    You have a single entry point (or a front controller) to which you redirect every request, and this front controller handles redirecting the request to the appropriate controller.

    # Redirect all requests that isn't a file or 
    # directory to your front controller
    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteRule .* index.php [L]
    

    The generic fallback rules will not append any parametes to the default/front controller. However, since it is an internal redirect, you will have access to the REQUEST_URI in PHP to determine what you should be doing.

    These are, naturally, not your only options. Just my 2 cents in the soup to stir a bit more.

    Disclaimer:
    All of the above rewrite rules (as well as everything else, of course) are written straight off the top of my head (after a few beers) and haven’t been tested anywhere.

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

Sidebar

Ask A Question

Stats

  • Questions 384k
  • Answers 384k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can start by going through the best practices that… May 14, 2026 at 11:07 pm
  • Editorial Team
    Editorial Team added an answer Same (partial)view You create only one but strong typed view… May 14, 2026 at 11:07 pm
  • Editorial Team
    Editorial Team added an answer Try: <script type="text/javascript" language="javascript"> $(function() { $('#testLink').click(function() { $.ajax({ type:… May 14, 2026 at 11:07 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.