Join David Powers for an in-depth discussion in this video Displaying the search results, part of PHP: Clean URLs on Apache Server.
- [Voiceover] Continuing from the previous video,…now that the intermediate file is generating a clean URL…for the search results, we need to…adjust the queries in the page that displays them.…That's result stop php, so let's switch to that file.…We want to use the value of search term…that's passed through the getaway…only if it's different from not found.…So, in this conditional statement on line two,…we need to add…and…get searchterm…is not equal…to not found.…
If there's no match, we need to start a session…inside the else block, because we're going to be using…the session variable that stores the value…that was entered into the fall.…So inside the else block, session start.…But if there is a value for search term,…we don't query the database.…But we've already queried…the database to find the search term,…so this time we can look for an exact match…by simplifying the where clause in both queries.…The first one is on line 12, so instead of where searchterm…is like searchterm, we make it an equal searchterm…and then get rid of the all clause.…
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