Join David Powers for an in-depth discussion in this video Testing whether Apache mod_rewrite is enabled, part of PHP: Clean URLs on Apache Server.
- [Voiceover] This is the example site…I'll be working with throughout this course.…It's not a complete site…and you won't be able to load it in your browser…until you set up the database later in this chapter.…Only the search form at the top right here…and the first three links in the navigation bar,…Arrangements, Fresh Flowers, and Care for Orchids, work.…But it's fairly typical of a database driven PHP site.…The URL in the browser address bar ends with the name…of the file including the PHP file name extension.…
So this is arrangements.php.…If I scroll down and click one of these images…it loads details.php with a query string on the end…indicating the arrangement id and its number.…And if I do a search, say for roses,…it loads results.php and again,…there is a query string on the end of the URL…with the search term.…URLs like this look quite ugly.…And they're difficult to remember.…
It would be so much nicer with a clean address,…like search/roses.…To create clean URLs on an Apache server…the mod_rewrite module needs to be enabled.…
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