Join David Powers for an in-depth discussion in this video Using RewriteMap with a text file, part of Clean PHP URLs on Apache Server.
- [Voiceover] RewriteMap is a really useful feature…that lets you map a list of name-value pairs to clean URLs…without the need for complex regular expressions.…In the previous chapter, we used a simple rewrite rule…to display the details of flower arrangements…in the example site by ending the clean URL…with the arrangements primary key.…So if I scroll down in the arrangements page,…and click one of the images,…it loads the details and the clean URL…ends simply with a number that's the ID.…
We can use RewriteMap to end the clean URL…with meaningful text rather than a number.…But the downside of RewriteMap is…that you can't register the map in an htaccess file.…It must be declared in the main Apache configuration file…or in the configuration file for virtual host.…So that may mean you can't use it in a hosting environment.…But anyway, let's take a look at how ReWriteMap works.…The simplest way to use RewriteMap is with a text file.…
So I'm going to switch to my editing program,…and I've got open generate_map.php,…
Rather than checking URLs individually, David shows how to evaluate and update them sitewide with the Apache mod_rewrite module. Watch these tutorials to learn how to enable mod_rewrite on your server, understand the structure of mod_rewrite rules, remove unnecessary file extensions, convert query strings into readable numbers and text, and use rewrite maps to look up complex values without regular expressions. Plus, learn how to enhance search results and provide searchers with links to specific parts of a webpage.
- Checking your Apache setup
- Creating simple regular expressions
- Removing .php from URLs
- Replacing query strings
- Displaying clean URLs in search results
- Linking to parts of a webpage
- Creating a clean URL for any PHP file